我用来PDO
在我的数据库中插入数据,但是我有一个date
表格,这是代码的一部分:
$name = "John Doe"; // from form
$bdate = 05/13/1989; // from form
$query = "INSERT INTO details (name, bdate) VALUES (:name, :bdate)";
$stmt = $this->handle->prepare($query);
$stmt->bindParam(':name',$name,PDO::PARAM_STR);
$stmt->bindParam(':bdate',$bdate,PDO::PARAM_STR);
$stmt->execute();
运行脚本后,我在日志中遇到此错误:"SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '05/13/1989' for column 'bdate' at row 1"。
我的数据库:
+-------+--------------+
| name | varchar(100) |
+-------+--------------+
| bdate | date |
+-------+--------------+