我把头撞在墙上。我已经检查了我可以考虑检查的所有内容,但出于某种原因,当我向MySQL发送日期时,它没有进入数据库。在PDO批量插入期间插入DateTime是否存在一些问题?
我有一个像这样的数组:
Array
(
[928] => Array
(
[lowResolutionUrl] => http://example.com/957208399_n.jpg
[thumbnailUrl] => http://example.com/957208399_n.jpg
[createdTime] => 2015-02-25 17:03:33
[link] => https://example.com/p/ziCbnMEW/
[location] => Here
[id] => 928
)
[922] => Array
(
[lowResolutionUrl] => http://example.com/1961049975_n.jpg
[thumbnailUrl] => http://example.com/1961049975_n.jpg
[createdTime] => 2015-02-25 17:00:26
[link] => https://example.com/p/ziCE12qc/
[location] => There
[id] => 922
)
etc.
)
我这样插入:
// Start Transaction
$this->_db->beginTransaction();
// Insert each record
foreach ($photos as $insertRow) {
// Prepare statement
$STH = $this->_db->prepare("INSERT IGNORE INTO photos (id, lowResolutionUrl, thumbnailUrl, createdTime, link, location)
VALUES (:id, :lowResolutionUrl, :thumbnailUrl, :createdTime, :link, :location)");
// now loop through each inner array to match binded values
foreach ($insertRow as $column => $value) {
$STH->bindParam(":{$column}", $value);
}
// Execute statement to add to transaction
$STH->execute();
// Clear statement for next record (not necessary, but good practice)
$STH = null;
}
// Commit all inserts
$this->_db->commit();
MySQL结构是这样的:
数组中的所有数据都被正确插入... createdTime
...
我可以在PHPMyAdmin控制台中以相同的格式手动插入DateTime ......发生了什么?