开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜