我在MySQL中有一个基于堆的表,我正试图通过PHP更新它,但由于某些原因,更新似乎没有发生。
下面是我的测试代码:
<?php
$freepoints[] = 1;
$freepoints[] = 2;
$freepoints[] = 3;
foreach ($freepoints as $entrypoint) {
$query = "update gates set lane='{$entrypoint}' where traffic > 50 limit 50";
echo "$query\n";
mysql_query($query);
echo mysql_affected_rows()."\n";
}
?>这将输出以下内容:
update gates set lane='1' where traffic > 50 limit 50
50
update gates set lane='2' where traffic > 50 limit 50
50
update gates set lane='3' where traffic > 50 limit 50
50在数据库中,从通道1/2/3开始有0条记录,通道4/5/6有100条记录。因此,我期望所有6个通道现在每个通道都有50条记录。但是,当我查看通道4/5/6时,仍然有100条记录,1/2/3仍然有0条记录。
当我将查询"update gate set lane='1‘where traffic > 50 limit 50“复制到phpMyAdmin中时,它工作得非常好,所以当mysql_affected_rows说它已经更新了50条记录时,你知道为什么它不能在我的PHP脚本中工作吗?
发布于 2010-03-31 17:13:52
https://stackoverflow.com/questions/2551639
复制相似问题