note 21941 added to function.mysql-list-tables

From: Date: Fri, 31 May 2002 16:13:31 +0000
Subject: note 21941 added to function.mysql-list-tables
Groups: php.notes 
Request: Send a blank email to php-notes+get-31297@lists.php.net to get a copy of this message
Here's a little function that will tell you if a table exists. (this function assumes an active db connection as well as a selected database) function mysql_table_exist($tableName) { $query = "SELECT COUNT(*) FROM $tableName"; $result = mysql_query($query); $num_rows = @mysql_num_rows($result); if($num_rows) { return TRUE; } else { return FALSE; } } Can't believe there isn't a function like this as part of the core MySQL support. (To be honest, there probebly is a function like this, I just over looked it. It would be like me to do things the hard way ;) ) -- http://www.php.net/manual/en/function.mysql-list-tables.php http://master.php.net/manage/user-notes.php?action=edit+21941 http://master.php.net/manage/user-notes.php?action=delete+21941 http://master.php.net/manage/user-notes.php?action=reject+21941

« previous php.notes (#31297) next »