variants of this question are asked on SO and in many blogs, but none of them give a direct answer. I hope there is one. I am updating PostgreSQL 9.0 (from CodeIgniter, PHP framework):
$sql_order = "UPDATE meters SET billed=true"; $query = $this->db->query($sql_order);
I just need the number of rows affected by the update, but it seems to be impossible with PostgreSQL. The query now returns boolean - true. Manual and web-based conversations refer to the RETURNING
, GET DIAGNOSTICS
syntax, and the default return type from UPDATE
. I could not get them to work. Is there an easy way to get strings to affect the count without inserting this simple operation into a procedure or transaction.
source share