即使where子句为true,示例中的update语句也不会一直有效。该数据库是MYSQL innodb。会导致某种锁定吗?这太奇怪了。
<?php
$query = 'SELECT id FROM TABLE1';
$result = db_query($query);
while($row = db_fetch_array($result)) {
//do some processing
db_query('UPDATE {TABLE1} SET updated = "1" WHERE id = "%s"',$row['id']);
}
?>
答案 0 :(得分:3)
语法错误 - MySQL不使用大括号:
db_query('UPDATE `TABLE1` SET updated = "1" WHERE id = "%s"',$row['id']);