2016-11-18, 08:59 PM
Sorry for such a basic question, but i am developing a very niche plugin with my minimal knowledge. I get many problems, but I usually sort them out after awhile. But for some reason, i just can't get my plugin to create a database table.
I am thankful for any insight on this. Thank you in Advance.
P.S. the commented out was my original idea for future convenience, if I decide to change the turn field amount.
function turnorder_install()
{
global $db;
$charset = $db->build_create_table_collation();
if(!$db->table_exists("turnorder")){
/*
$a=1;
$columnNumber="";
while($a<=10){
$columnNumber .= "turn".$a." VARCHAR(30),
";
$a++;
}
rtrim($columnNumber, ",");
$createTable = "CREATE TABLE mybb_turnorder (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
thread SMALLINT(5) NOT NULL,
lastPosition TINYINT(2) DEFAULT 1 UNSIGNED,
".$columnNumber." )";
*/
$createTable = "CREATE TABLE mybb_turnorder (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
thread SMALLINT(5) NOT NULL,
lastPosition TINYINT(2) DEFAULT 1 UNSIGNED,
turn1 VARCHAR(30),
turn2 VARCHAR(30),
turn3 VARCHAR(30),
turn4 VARCHAR(30),
turn5 VARCHAR(30),
turn6 VARCHAR(30),
turn7 VARCHAR(30),
turn8 VARCHAR(30),
turn9 VARCHAR(30),
turn10 VARCHAR(30))";
$tableOrder = mysqli_query($db, $createTable);
}
}
I am thankful for any insight on this. Thank you in Advance.
P.S. the commented out was my original idea for future convenience, if I decide to change the turn field amount.