At 3:37 PM -0500 9/19/03, Don Read wrote:
On 19-Sep-2003 Don Read wrote:

On 19-Sep-2003 Dan Anderson wrote:
I am trying to make my PHP script autodetect when a table in a mySQL
database exists, and when it doesn't, create it.


<snip>

 function tableexists($tbl) {
     $res = @mysql_query("SELECT 1 FROM $tbl");
     return ($res ? true : false);
 }


Err ... make that


$res = @mysql_query("SELECT 1 FROM $tbl LIMIT 1");

Better yet, SELECT 1 FROM $tbl WHERE 1 = 0, which returns even fewer rows. :-)

Or use SHOW TABLES LIKE 'name of table here' or
SHOW TABLE STATUS LIKE 'name of table here' and see if you
get any row back.


-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com

Are you MySQL certified? http://www.mysql.com/certification/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to