note 22163 added to function.mysql-list-tables

From: Date: Sun, 09 Jun 2002 05:23:34 +0000
Subject: note 22163 added to function.mysql-list-tables
Groups: php.notes 
Request: Send a blank email to php-notes+get-31613@lists.php.net to get a copy of this message
I was also surprised to find there's no function that lets you test for the existence of a table. There's a few problems with the solution offered above. For one thing, it's perfectly possible (and legal) for a table to have no records - a condition that would not be caught by this function. Here's a better way to do it: function mysql_table_exists($dbLink, $database, $tableName) { $tables = array(); $tablesResult = mysql_list_tables($database, $dbLink); while ($row = mysql_fetch_row($tablesResult)) $tables[] = $row[0]; return(in_array($tableName, $tables)); } -- http://www.php.net/manual/en/function.mysql-list-tables.php http://master.php.net/manage/user-notes.php?action=edit+22163 http://master.php.net/manage/user-notes.php?action=delete+22163 http://master.php.net/manage/user-notes.php?action=reject+22163

« previous php.notes (#31613) next »