View Full Version : if table exists?
pyro.699
11-15-2005, 09:15 PM
whats the php code, for
'If this table exists... do this'?
Zachariah
11-15-2005, 09:20 PM
CREATE TABLE IF NOT EXISTS `table_name`
IF NOT, IF
pyro.699
11-15-2005, 09:31 PM
what if its not a table? i need to make a coloum in the user table
akanevsky
11-15-2005, 10:00 PM
ALTER TABLE IF EXISTS `table_name` ADD `column_name`...
pyro.699
11-15-2005, 10:16 PM
$db->query_write(
"ALTER TABLE IF EXISTS user ADD top_game_sites INT( 1 ) NOT NULL");
that dosent really work...
Marco van Herwaarden
11-16-2005, 05:22 AM
To test if a column exists, you cna use the following query:
SHOW COLUMNS FROM <tablename> WHERE field = '<columnname>';
Alternative you could disable error reporting and just run the query to add the column.
pyro.699
11-16-2005, 01:14 PM
could i have the exact code? i need to add a feild to the 'user' table, called 'xtreme_top_100' and thats it
Marco van Herwaarden
11-16-2005, 02:08 PM
turn off error reporting:
$db->reporterror = false;
$db->query_write(".....");
$db->reporterror = true;
The other option for first testing, i think you can figure that our yourself.
pyro.699
11-16-2005, 02:21 PM
lol :P
and thanks ^^
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.