使用以下代码中的 SQL:
public function saveOrder() {
$id = $this->getUserId();
$this->db->query("INSERT INTO orders VALUES (null, '$id', '$this->basket_lines', '$this->total', NOW() )");
return $this->db->id();
}
上面的最后一列是DATETIME
字段,数据库中的结果默认为0000-00-00 00:00:00
.
我也尝试过列格式timestamp
并使用:
ALTER TABLE `content ` CHANGE `date` `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
从另一个帖子,但无济于事。
谁能发现什么问题?
谢谢
编辑:顺便说一句,我正在使用从 DB 类中转义我的 SQL 语句
$this->SQL = $this->mysqli->real_escape_string($SQL);
$this->result = $this->mysqli->query($SQL);
编辑 2:我现在正在逃避预查询
$i=mysql_real_escape_string($id);
$b=mysql_real_escape_string($this->basket_lines);
$t=mysql_real_escape_string($this->total);
$this->db->query("INSERT INTO orders VALUES (null, '$i', '$b', '$t', NOW() )");
仍然无法正常工作,这一切都很奇怪吗?