[geeklog-cvs] geeklog: fixed DB_getItem

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Tue Jan 26 15:53:52 EST 2010


changeset 7645:4631b645ed06
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/4631b645ed06
user: stan <yankees26an at gmail.com>
date: Fri Aug 07 12:35:33 2009 -0400
description:
fixed DB_getItem

diffstat:

 system/lib-database.php |  31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r 25a8200b0461 -r 4631b645ed06 system/lib-database.php
--- a/system/lib-database.php	Sat Aug 01 18:49:17 2009 -0400
+++ b/system/lib-database.php	Fri Aug 07 12:35:33 2009 -0400
@@ -265,13 +265,32 @@
 */
 function DB_getItem($table,$what,$selection='')
 {
-    if (!empty($selection)) {
-        $result = DB_query("SELECT $what FROM $table WHERE $selection");
-    } else {
-        $result = DB_query("SELECT $what FROM $table");
+    global $_DB_dbms;
+    if($_DB_dbms=='mysql')
+    {
+        if (!empty($selection)) {
+            $result = DB_query("SELECT $what FROM $table WHERE $selection");
+        } else {
+            $result = DB_query("SELECT $what FROM $table");
+        }
+        $ITEM = DB_fetchArray($result, true);
+        return $ITEM[0];
     }
-    $ITEM = DB_fetchArray($result, true);
-    return $ITEM[0];
+    elseif($_DB_dbms=='pgsql')
+    {
+        $result = DB_query("SELECT check_table('$table', 'public');");
+        $row=DB_fetchArray($result);
+        if(!empty($row[0]))
+        {     //table exists
+             if(!empty($selection)) {$result = DB_query("SELECT $what FROM $table WHERE $selection");}
+             else {$result = DB_query("SELECT $what FROM $table");}
+             
+             $ITEM = DB_fetchArray($result, true);
+             return $ITEM[0];   
+        }
+    }
+    else{ COM_errorLog ('Unknown DB selected', 3);}
+    
 }
 
 /**



More information about the geeklog-cvs mailing list