开发者

postgresql 9. update not working

开发者 https://www.devze.com 2023-03-16 07:30 出处:网络
I am using PostgreSQL 9. When trying to do this update, row table does not get updated. $cmd = \"UPDATE table1 SET field1 = \'$value1\'WHERE key_field = \'$key_value\'; \";

I am using PostgreSQL 9. When trying to do this update, row table does not get updated.

$cmd = "UPDATE table1 SET field1 = '$value1'  WHERE key_field = '$key_value'; ";

table1 has privileges for PUBLIC to INSERT and UPDATE.

When using pgAdmin III SQL co开发者_Go百科nsole it does perfectly the job.


  1. Don't use variable parsing (or string concatenation) to build SQL queries;

  2. What does "using PgAdminIII sql console it does perfectly the job" mean? You have pasted the same query in pgAdmin3 and it worked? I very much doubt pgAdmin3 understands PHP and does PHP-style variable parsing as a consequence. If it was not exactly the same query (most probably it was one with the PHP variables replaced with literals) what was the query you tested in pgAdmin3?

  3. Most probably the reason the update is ineffective is that there are no rows that satisfy your WHERE clause.


$cmd = "UPDATE table1 SET field1 = '$value1' WHERE key_field = '$key_value'";

Now try there was an extra ;

0

精彩评论

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