Page 1 of 1

Checking if table exists

Posted: Thu Feb 23, 2006 8:46 am
by rockboy
hello

i'm trying to write a function which creates tables when they don't already exist, i have seen the mysql_list_tables function and could build something of that but i was wondering if there was already a cleaner way of doing this.

eg:

Code: Select all

if (table_exists("members")){
....
}
thanx

Posted: Thu Feb 23, 2006 9:59 am
by feyd
there's two sides: checking, or telling MySQL to create it always (with the constraint that the table must not exist to run it).

for the latter, check the CREATE TABLE documentation.

http://dev.mysql.com/doc/refman/4.1/en/ ... table.html