Welcome Guest, Not a member yet? Register   Sign In
postgresql INSERT ... RETURNING and db->query()
#1

[eluser]Unknown[/eluser]
postgresql 8.2+ allows INSERT ... RETURNING ... queries, but db->query() does not return the results (only TRUE). query() should return the results just as SELECT does.

Temporarily I changed this line in DB_driver.php:
Code:
if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
to this
Code:
if ( ! preg_match('/^\s*"?(SET|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
but I don't think this is right answer.

Dwayne
#2

[eluser]Unknown[/eluser]
My general solution was to update the DB_driver.php from

Code:
public function is_write_type($sql)
{
  return (bool) (preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql);
}

to:

Code:
public function is_write_type($sql)
{
  return (bool) (preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql) && !preg_match('/ RETURNING /i', $sql));
}





Theme © iAndrew 2016 - Forum software by © MyBB