PDA

View Full Version : How do i creat a table in mysql?


dxlwebs
07-20-2009, 08:26 AM
hey all first i would like to say sorry for this dumb question but im creating a feature for my mod and my wife is due to give birth tomorrow and for some reason my mind is just blank when it comes to mysql today but i have to finish this today before the baby is born!

basically what i want to do is creat a new table! here's what i have written!(or can remember)


<installcode><![CDATA[
$db->hide_errors();
$vbulletin->db->query_write("
CREATE TABLE IF NOT EXISTS `". TABLE_PREFIX ."table1 `(
`test` smallint(6) unsigned NOT NULL auto_increment,
`test2` varchar(250) collate latin1_general_ci NOT NULL,
`test3` varchar(250) collate latin1_general_ci NOT NULL,
`test4` tinyint(1) NOT NULL default '0',
`test5` tinyint(1) unsigned NOT NULL,
`test6` int(10) unsigned NOT NULL,
`test7` smallint(6) unsigned NOT NULL,
PRIMARY KEY (`test`),
KEY `threadid` (`threadid`)
) ENGINE=MyISAM ");]]></installcode>
<uninstallcode><![CDATA[$vbulletin->db->query_write("DROP table " . TABLE_PREFIX . "table1");]]></uninstallcode>


if some one could please remind me what to do that would be great i really can't believe how i have forgotten what to do! but basically what i have written doesnt seem to write any tables at all!

thanks for your help

Marco van Herwaarden
07-20-2009, 10:43 AM
Remove the hide_errors, so you can see what goes wrong. But my guess is that you will receive a message that the column 'threadid' is not known.

dxlwebs
07-20-2009, 03:46 PM
hmm possibly if someone could post how it is suppost to be done that would be creat

Lynne
07-20-2009, 04:00 PM
Just download a mod that adds a table and you will see how it's done. I would guess a mod like the arcade would add a table.

Marco van Herwaarden
07-21-2009, 12:05 PM
How what is supposed to be done?

You have at least 1 error in the query as you are defining a KEY for a column that doesn't exist.