From: Brion Vibber Date: Wed, 24 Mar 2004 07:49:50 +0000 (+0000) Subject: mysql_list_tables() is deprecated; switch to more elegant solution used X-Git-Tag: 1.3.0beta1~705 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=68b801e9873c97c564cb6d06f5fe7c7e4e9b1575;p=lhc%2Fweb%2Fwiklou.git mysql_list_tables() is deprecated; switch to more elegant solution used in REL1_2 branch. --- diff --git a/includes/Database.php b/includes/Database.php index fac49592a1..64cfbf11fa 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -332,16 +332,15 @@ class Database { function tableExists( $table ) { - $res = mysql_list_tables( $this->mDBname ); - if( !$res ) { - echo "** " . $this->lastError() . "\n"; + $old = $this->mIgnoreErrors; + $res = $this->query( "SELECT 1 FROM $table LIMIT 1" ); + $this->mIgnoreErrors = $old; + if( $res ) { + $this->freeResult( $res ); + return true; + } else { return false; } - $nTables = $this->numRows( $res ); - for( $i = 0; $i < $nTables; $i++ ) { - if( mysql_tablename( $res, $i ) == $table ) return true; - } - return false; } function fieldInfo( $table, $field )