News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

why dont this create the table

Started by SA™, April 11, 2009, 09:23:41 PM

Previous topic - Next topic

SA™

// add the users property table
$smcFunc['db_create_table']('shop_inv',
array(
array(
'name' => 'id',
'type' => 'int',
'size' => 10,
'auto' => true,
),
array(
'name' => 'userid',
'type' => 'int',
'size' => 10,
),
array(
'name' => 'itemid',
'type' => 'int',
'size' => 10,
),
array(
'name' => 'trading',
'type' => 'tinyint',
'size' => 10,
),
array(
'name' => 'tradecost',
'type' => 'decimal',
'size' => 10,
),
array(
'name' => 'amtpaid',
'type' => 'decimal',
'size' => 10,
),
array(
'name' => 'comment',
'type' => 'tinytext',
'size' => 10,
),
),
array(
array(
'name' => 'id',
'type' => 'primary',
'columns' => array('id'),
),
),
array(),
'ignore');



it dont give no errors just dont create the table


from using debug i can see this


REATE TABLE smf_shop_inv

`id` int(10) NOT NULL auto_increment,
`userid` int(10) NOT NULL ,
`itemid` int(10) NOT NULL ,
`trading` tinyint(10) NOT NULL ,
`tradecost` decimal(10) NOT NULL ,
`amtpaid` decimal(10) NOT NULL ,
`comment` tinytext(10) NOT NULL ,
PRIMARY KEY (id)) TYPE=MyISAM
in C:\xampp\htdocs\shop\Packages\temp\installScript.php line 115, which took 0.00030398 seconds.



notice its only showing

REATE TABLE

instead of

CREATE TABLE

i dont understand why

i have the SMF2 extra db funtion included in my script
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

retis

check the function is including the C, the debug could just be missing it off i guess but i'd start there. The actual query looks fine, so i;d assume either this or some form of permissions eror, but i imagine it;s the former.

SA™

i dont know what ya mean by that the code should be ok my other tables create justn not that one :(
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

retis

so you have already used the same function to create other tables? if i am understanding correctly?

M-DVD


Adish - (F.L.A.M.E.R)

Quote from: retis on April 11, 2009, 10:39:41 PM
check the function is including the C, the debug could just be missing it off i guess but i'd start there. The actual query looks fine, so i;d assume either this or some form of permissions eror, but i imagine it;s the former.


Quote from: MAD Coder on April 12, 2009, 02:12:59 AM
i dont know what ya mean by that the code should be ok my other tables create justn not that one :(

He means to put the C in front of REATE and then run the script to check if it creates it right or not.
I would suggest the same. :)

SA™

tryed it dont work

// add the users property table
$smcFunc['db_create_table']('shop_inv',
array(
array(
'name' => 'id',
'type' => 'int',
'size' => 10,
'auto' => true,
),
array(
'name' => 'userid',
'type' => 'int',
'size' => 10,
),
array(
'name' => 'itemid',
'type' => 'int',
'size' => 10,
),
array(
'name' => 'trading',
'type' => 'tinyint',
'size' => 10,
),
array(
'name' => 'tradecost',
'type' => 'decimal',
'size' => 10,
),
array(
'name' => 'amtpaid',
'type' => 'decimal',
'size' => 10,
),
array(
'name' => 'comment',
'type' => 'tinytext',
'size' => 10,
),
),
array(
array(
'name' => 'id',
'type' => 'primary',
'columns' => array('id'),
),
),
array(),
'ignore');


wheni use


$smcFunc['db_query']('',"
CREATE TABLE IF NOT EXISTS {db_prefix}shop_property (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`userid` INT UNSIGNED NOT NULL,
`itemid` INT UNSIGNED NOT NULL,
`trading` TINYINT UNSIGNED NOT NULL,
`tradecost` DECIMAL(8,2) UNSIGNED NOT NULL,
`amtpaid` DECIMAL(8,2) UNSIGNED NOT NULL,
`comment` TINYTEXT NOT NULL,
PRIMARY KEY (`id`)
)");



it works only thats not the way todo it
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Adish - (F.L.A.M.E.R)

Are you putting that query into your database? or in a file ?

If its a file, then it works differently. The query without $smcFunc['db_query'](''," should probably work in the database.

SA™

hmm im realy lost here


attached is the installer if that helps


exscuse the mess lol
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Adish - (F.L.A.M.E.R)

ok, the code goes in the file, so basically it needs to ideantify what the content it is. So to define that, you have said that its a Database query by using the code ---> $smcFunc['db_query']('',"

Thats why i think it works when you add that, while it doesnt by just writing Create Table.


Edit:-
I came up with this conclusion by checking the install2.php in Simpleportal. It has this function before the database queries it needs to make.

Bulakbol

Quote$smcFunc['db_create_table'] (table_name, columns, indexes, parameters, if_exists, error) - with db_extend('packages');

Did you globalize the db_extend('packages')?
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

onepiece

A text field cannot have a size value.

Code (Find) Select
'name' => 'comment',
'type' => 'tinytext',
'size' => 10,


Code (Replace) Select
'name' => 'comment',
'type' => 'tinytext',

SA™

tthanks that worked now im facing more problems with tables not creating


$smcFunc['db_create_table']('shop_item',
array(
array(
'name' => 'itemid',
'type' => 'int',
'size' => 10,
'auto' => true,
),
array(
'name' => 'name',
'type' => 'varchar',
'size' => 50,
),
array(
'name' => 'description',
'type' => 'text',
),
array(
'name' => 'price',
'type' => 'decimal',
'size' => '8,2',
'default' => '0.00',
),
array(
'name' => 'module',
'type' => 'tinytext',
),
array(
'name' => 'count',
'type' => 'smallint',
'size' => 6,
),
array(
'name' => 'info1',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info2',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info3',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info4',
'type' => 'text',
'null' => true,
),
array(
'name' => 'input_needed',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'can_use_item',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'delete_after_use',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'image',
'type' => 'tinytext',
'null' => true,
),
array(
'name' => 'catid',
'type' => 'smallint',
'size' => 6,
'default' => 0,
),
array(
'name' => 'status',
'type' => 'text',
'size' => 6,
'default' => 0,
),
),
array(
array(
'name' => 'itemid',
'type' => 'primary',
'columns' => array('id'),
),
),
array(),
'ignore');


and this one needs to skip if theere allready there


// Insert shop defult items
$smcFunc['db_insert']('insert', $db_prefix . 'shop_item',

// Fields
array(
'name' => 'string',
'description' => 'string',
'price' => 'float',
'count' => 'int',
'image' => 'string',
'module' => 'string',
'info1' => 'int',
'info2' => 'int',
'input_needed' => 'int',
'can_use_item' => 'int',
'delete_after_use' => 'int',
'catid' => 'int',
'status' => 'int',
),

// Values
array(
// testitem
array(
'name' => 'Test Item',
'description' => 'Just a test item!',
'price' => 10.00,
'count' => 50,
'image' => 'Airplane.gif',
'module' => 'testitem',
'info1' => 0,
'info2' => 0,
'input_needed' => 0,
'can_use_item' => 0,
'delete_after_use' => 0,
'catid' => 1,
'status' => 1,
),

// RandomMoney
array(
'name' => 'Random Money',
'description' => 'Get a random amount of money, between -190 and 190!',
'price' => 75,
'count' => 50,
'image' => 'Bear.gif',
'module' => 'RandomMoney',
'info1' => -190,
'info2' => 190,
'input_needed' => 0,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// AddToPostCount
array(
'name' => 'Add 100 to Post Count',
'description' => 'Increase your Post Count by 100!',
'price' => 50,
'count' => 50,
'image' => 'Boardarrow.gif',
'module' => 'AddToPostCount',
'info1' => 100,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// IncreaseKarma
array(
'name' => 'Increase Karma',
'description' => 'Increase your Karma by 5',
'price' => 100,
'count' => 50,
'image' => 'Breadandbutter.gif',
'module' => 'IncreaseKarma',
'info1' => 5,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// ChangeUsername
array(
'name' => 'Change Username',
'description' => 'Change your Username!',
'price' => 50,
'count' => 50,
'image' => 'Claspknife.gif',
'module' => 'ChangeUsername',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// ChangeUserTitle
array(
'name' => 'Change User Title',
'description' => 'Change your User Title',
'price' => 50,
'count' => 50,
'image' => 'Clip.gif',
    'module' => 'ChangeUserTitle',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// IncreaseTimeLoggedIn
array(
'name' => 'Increase Total Time',
'description' => 'Increase your total time logged in by 12 hours.',
'price' => 50,
'count' => 50,
'image' => 'Compactdiscs.gif',
'module' => 'IncreaseTimeLoggedIn',
'info1' => 43200,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// ChangeOtherTitle
array(
'name' => 'Change Other\'s Title',
'description' => 'Change someone else\'s title',
'price' => 200,
'count' => 50,
'image' => 'Controller.gif',
'module' => 'ChangeOtherTitle',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// DecreasePost
array(
'name' => 'Decrease Posts by 100',
'description' => 'Decrease <i>Someone else\'s</i> post count by 100!',
'price' => 200,
'count' => 50,
'image' => 'Darkbeer.gif',
'module' => 'DecreasePost',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// StickyTopic
array(
'name' => 'Sticky Topic',
'description' => 'Make any one of your topics a sticky!',
'price' => 400,
'count' => 50,
'image' => 'Dousojin.gif',
'module' => 'StickyTopic',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// StickyTopic
array(
'name' => 'Steal Credits',
'description' => 'Try to steal credits from another member!',
'price' => 50,
'count' => 50,
'image' => 'Dutchoven.gif',
'module' => 'Steal',
'info1' => 40,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// Rock
array(
'name' => 'Rock',
'description' => 'Well... It does nothing',
'price' => 5,
'count' => 50,
'image' => 'Dxtwoburner.gif',
'module' => 'Rock',
'info1' => 40,
'info2' => 0,
'input_needed' => 0,
'can_use_item' => 0,
'delete_after_use' => 0,
'catid' => 1,
'status' => 1,
),

// ChangeDisplayName
array(
'name' => 'Change Display Name',
'description' => 'Change your display name!',
'price' => 5,
'count' => 50,
'image' => 'Figure.gif',
'module' => 'ChangeDisplayName',
'info1' => 0,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),

// gamespass
array(
'name' => 'Games Room Pass',
'description' => 'Allows access to Games Room for xxx days',
'price' => 50,
'count' => 50,
'image' => 'Figure.gif',
'module' => 'gamespass',
'info1' => 30,
'info2' => 0,
'input_needed' => 1,
'can_use_item' => 1,
'delete_after_use' => 1,
'catid' => 1,
'status' => 1,
),
),
array());
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

onepiece

First one.

The name of columns to be the key should be in the 'columns' index.

Code (Find) Select
'columns' => array('id'),

Code (Replace) Select
'columns' => array('itemid'),

Second.

The best you can do is to check if they already exists with a query before this one; and run this depending on the result you get.

SA™

still not working


// Item table
$smcFunc['db_create_table']('shop_item',
array(
array(
'name' => 'itemid',
'type' => 'int',
'size' => 10,
'auto' => true,
),
array(
'name' => 'name',
'type' => 'varchar',
'size' => 50,
),
array(
'name' => 'description',
'type' => 'text',
),
array(
'name' => 'price',
'type' => 'decimal',
'size' => '8,2',
'default' => '0.00',
),
array(
'name' => 'module',
'type' => 'tinytext',
),
array(
'name' => 'count',
'type' => 'smallint',
'size' => 6,
),
array(
'name' => 'info1',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info2',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info3',
'type' => 'text',
'null' => true,
),
array(
'name' => 'info4',
'type' => 'text',
'null' => true,
),
array(
'name' => 'input_needed',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'can_use_item',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'delete_after_use',
'type' => 'tinyint',
'size' => 1,
'default' => 0,
),
array(
'name' => 'image',
'type' => 'tinytext',
'null' => true,
),
array(
'name' => 'catid',
'type' => 'smallint',
'size' => 6,
'default' => 0,
),
array(
'name' => 'status',
'type' => 'text',
'size' => 6,
'default' => 0,
),
),
array(
array(
'name' => 'itemid',
'type' => 'primary',
'columns' => array('itemid'),
),
),
array(),
'ignore');
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

onepiece

The same error you have again.

      array(
         'name' => 'status',
         'type' => 'text',
         'size' => 6,
         'default' => 0,
      ),


TEXT fields cannot have a default and size attributes.

Dragooon

Quote from: Tenma on April 22, 2009, 05:02:39 AM
TEXT fields cannot have a default and size attributes.
TEXT fields can have a default attribute but it must be a string.

onepiece

They can't, at least in MySQL.

http://dev.mysql.com/doc/refman/5.0/en/blob.html

QuoteBLOB and TEXT columns cannot have DEFAULT values.

Dragooon

Ah really? Didn't know that. VARCHAR and tinytext columns can have default values though. Thanks.

onepiece

VARCHAR can have, but All TEXT types (TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT) cannot have default values. You're welcome.

Advertisement: