开发者

Why is my SQL UPDATE statement not working in a loop?

开发者 https://www.devze.com 2023-01-05 04:03 出处:网络
The update statement in example is not working all the time even开发者_JS百科 though the where clause is true. The database is MYSQL innodb. Would that cause some sort of locking ?? This is so weird.

The update statement in example is not working all the time even开发者_JS百科 though the where clause is true. The database is MYSQL innodb. Would that cause some sort of locking ?? This is so weird.

<?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']);
    }
?>


The syntax is wrong - MySQL doesn't use curly brackets:

db_query('UPDATE `TABLE1` SET updated = "1" WHERE id = "%s"',$row['id']);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号