![]() |
Mod Create new Table..
Hey im working on a plugin and i want this plugin to create a new table in the database and i don´t know how i should get it work i only get error so can somebody give the code that creates a new table that i can put in?
|
Just Google "MySQL Create Table" you will get loads of tutorials/guides and the official documentation.
|
$db->query_write("CREATE TABLE test (testid integer NOT NULL PRIMARY KEY auto_increment, testname text)");
|
Quote:
Code:
Database error in vBulletin 3.7.0 Beta 3: |
date and time are MySQL keywords I think and also text. Make sure the column names aren't the same as the column types. Also enclose the column names in single quotes.
|
i tried this now
Code:
$db->query_write("CREATE TABLE " . TABLE_PREFIX . "news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, date varchar, time varchar, poster varchar, newst text)"); Code:
Database error in vBulletin 3.7.0 Beta 3: |
You can't name a field "date" or "time", you need to rename those, ex:
Code:
$db->query_write("CREATE TABLE " . TABLE_PREFIX . "news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, newsdate varchar, newstime varchar, poster varchar, newst text)"); |
Quote:
but i still get error when i use the one you wrote here. Code:
Database error in vBulletin 3.7.0 Beta 3: |
Varchar type requires a length. Not optional.
Code:
CREATE TABLE vb_news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar(128), newsdate varchar(10), newstime varchar(10), poster varchar(32), newst text); |
Quote:
--------------- Added [DATE]1200518572[/DATE] at [TIME]1200518572[/TIME] --------------- okey got another question related to this. i want the date to be saved like MM/DD/YYYY but i want it to be shown as the option says in acp. like this: 1st January 2008 |
All times are GMT. The time now is 12:27 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|