PDO 不会运行相同的查询两次吗?
再会!
我试图使用相同的参数运行相同的更新语句两次,但在第二种情况下它似乎没有执行:
$update_query = $this->db->connection->prepare('UPDATE `Table SET `field` = :price WHERE (`partnum` = :partnum)');
$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 1
// If I insert here any statement it works as expected
$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 0!
我没有启用 mysql 查询缓存。
谢谢!
Good day!
I'm trying to run the same update statement with the same params twice and it seems that it is not executed in the second case:
$update_query = $this->db->connection->prepare('UPDATE `Table SET `field` = :price WHERE (`partnum` = :partnum)');
$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 1
// If I insert here any statement it works as expected
$update_query->execute(array('price' => 123, 'partnum' => test));
var_dump($update_query->rowCount()); //returns 0!
I do not have mysql query cache enabled.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
UPDATE
没有更改一行中的数据,MySQL
不会将此行计为受影响:第二个
UPDATE
语句确实执行,但没有影响任何行从MySQL
的角度来看,因为它没有改变任何东西。If
UPDATE
changes no data in a row,MySQL
doesn't count this row as affected:The second
UPDATE
statement did execute but affected no rows fromMySQL
's point of view, since it changed nothing.