AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL Database query, make db if not there... (https://forums.alliedmods.net/showthread.php?t=6168)

ThantiK 09-23-2004 04:58

SQL Database query, make db if not there...
 
Would someone mind throwing me some examples of accessing a database and table...checking if they exist, and if they dont exist, create them and the necessary fields?

I already have the database ACCESS, writing, etc all down, but am somewhat stumped on how to tell if a database exists before accessing, and creating these things if they dont exist.

Geesu 09-23-2004 08:32

here is a create if not exists...

format (mquery, 511, "CREATE TABLE IF NOT EXISTS `%s` ( `playerid` VARCHAR(35) NOT NULL, `playername` VARCHAR(35) NOT NULL, `xp` INT(11) NOT NULL, `race` TINYINT(4) NOT NULL, `skill1` TINYINT(4), `skill2` TINYINT(4), `skill3` TINYINT(4), `skill4` TINYINT(4), `time` TIMESTAMP( 14 ) NOT NULL, PRIMARY KEY (playerid,race))",mysqltablename)


All times are GMT -4. The time now is 17:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.