Index: trunk/kernel/include/itemdb.php =================================================================== diff -u -N -r4077 -r7867 --- trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 4077) +++ trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 7867) @@ -371,7 +371,7 @@ { global $Errors; - $sql = "INSERT IGNORE INTO ".$this->tablename." ("; + $sql = "INSERT INTO ".$this->tablename." ("; $first = 1; foreach ($this->Data as $key => $value) { @@ -654,18 +654,28 @@ function TableExists($table = null) { - // checks if table specified in item exists in db - $db =& GetADODBConnection(); - $sql = "SHOW TABLES LIKE '%s'"; - if($table == null) $table = $this->tablename; - $rs = $db->Execute( sprintf($sql, $table) ); + static $tables_found = Array (); - if( $rs->RecordCount() == 1 ) // table exists in normal case - return 1; - else // check if table exists in lowercase - $rs = $db->Execute( sprintf($sql, strtolower($table) ) ); + if ($table == null) $table = $this->tablename; - return ($rs->RecordCount() == 1) ? 1 : 0; + if (!isset($tables_found[$table])) { + // checks if table specified in item exists in db + $db =& GetADODBConnection(); + $sql = "SHOW TABLES LIKE '%s'"; + + $rs = $db->Execute( sprintf($sql, $table) ); + if ($rs->RecordCount() == 1) { + // table exists in normal case + $tables_found[$table] = 1; + } + else { + // check if table exists in lowercase + $rs = $db->Execute( sprintf($sql, strtolower($table) ) ); + $tables_found[$table] = $rs->RecordCount() == 1 ? 1 : 0; + } + } + + return $tables_found[$table]; } function raiseEvent($name, $id = null)