Update of /cvsroot/php-blog/serendipity/include/db
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19783/include/db
Modified Files:
postgres.inc.php
Log Message:
Fix for postgresql 8.0 to not rely on OID features.
Index: postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/postgres.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- postgres.inc.php 16 Feb 2005 12:56:42 -0000 1.11
+++ postgres.inc.php 21 Feb 2005 12:12:15 -0000 1.12
@@ -76,16 +76,16 @@
function serendipity_db_insert_id($table = '', $id = '') {
global $serendipity;
if (empty($table) || empty($id)) {
+ // BC - will/should never be called with empty parameters!
return pg_last_oid($serendipity['dbLastResult']);
} else {
- $oid = pg_last_oid($serendipity['dbLastResult']);
- $query = "SELECT $id FROM {$serendipity['dbPrefix']}$table WHERE oid=$oid";
+ $query = "SELECT currval('{$serendipity['dbPrefix']}{$table}_{$id}_seq'::text) AS {$id}";
$res = pg_query($serendipity['dbConn'], $query);
if (pg_num_rows($res)) {
$insert_id = pg_fetch_array($res, 0, PGSQL_ASSOC);
return $insert_id[$id];
} else {
- return $oid;
+ return pg_last_oid($serendipity['dbLastResult']); // BC - should not happen!
}
}
}
|