[geeklog-cvs] Geeklog-1.x/system lib-database.php,1.52,1.53
Michael Jervis
mjervis at qs1489.pair.com
Thu Aug 14 12:52:30 EDT 2008
Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv42344/system
Modified Files:
lib-database.php
Log Message:
Eliminated use of REPLACE INTO, introduced DB_checkTableExists.
Index: lib-database.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-database.php,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** lib-database.php 12 Apr 2008 11:21:46 -0000 1.52
--- lib-database.php 14 Aug 2008 16:52:02 -0000 1.53
***************
*** 538,540 ****
--- 538,568 ----
}
+ /**
+ * Check if a table exists
+ *
+ * @param string $table Table name
+ * @return boolean True if table exists, false if it does not
+ *
+ */
+ function DB_checkTableExists($table)
+ {
+ global $_TABLES, $_DB_dbms;
+
+ $exists = false;
+
+ if ($_DB_dbms == 'mysql') {
+ $result = DB_query ("SHOW TABLES LIKE '{$_TABLES[$table]}'");
+ if (DB_numRows ($result) > 0) {
+ $exists = true;
+ }
+ } elseif ($_DB_dbms == 'mssql') {
+ $result = DB_Query("SELECT 1 FROM sysobjects WHERE name='{$_TABLES[$table]}' AND xtype='U'");
+ if (DB_numRows ($result) > 0) {
+ $exists = true;
+ }
+ }
+
+ return $exists;
+ }
+
?>
More information about the geeklog-cvs
mailing list