News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Mod Authors: SMF 2.0 Database Functions

Started by SleePy, February 21, 2008, 05:57:21 PM

Previous topic - Next topic

Akyhne

It creates the table as expected, but gives an error when run twice. It should just use the 'if not exists' with the 'ignore' option.


Kays

Ignore should work. Try adding an empty array before ignore.


),
array(),
'ignore'
);



If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Akyhne

I already tried that, and it didn't work.

Kays

The only other difference I can see to one which works is that


$db_prefix . 'collection',


should be:


'{db_prefix}collection',


But I don't think that is it since the table does get created. However... :)

What error do you get on re-running it?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

SA™

this should work

<?php

$smcFunc['db_create_table']('{db_prefix}collection',
array(
array('name' => 'item''type' => 'INT''size' => 11'default' => 0'auto' => 'true'),
array('name' => 'name''type' => 'VARCHAR''size' => 60'default' => ''),
array('name' => 'pop_name''type' => 'VARCHAR''size' => 30'default' => ''),
array('name' => 'category''type' => 'INT''size' => 11'default' => 0),
array('name' => 'thumb''type' => 'VARCHAR''size' => 60'default' => ''),
array('name' => 'official_site''type' => 'TEXT''default' => ''),
array('name' => 'other_site''type' => 'TEXT''default' => ''),
),
array(
array(
'type' => 'primary',
'columns' => array('item')
),
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 -___-

Alpay

hi ;

db_query ( "CREATE TABLE IF NOT EXISTS `{$db_prefix}rivals_clanladders` (
  `clan_id` int(1) NOT NULL,
  `ladder_id` int(1) NOT NULL
)",__FILE__,__LINE__ );


Would you help translate for Smf 2x ?

grafitus

@Alpay, use this:
if (!isset($smcFunc['db_create_table'])
db_extend('packages');

$smcFunc['db_create_table'] ('{db_prefix}rivals_clanladders',
array(
array(
'name' => 'clan_id',
'type' => 'tinyint',
'size' => '1',
),
array(
'name' => 'ladder_id',
'type' => 'tinyint',
'size' => '1',
),
),
array()
);

Alpay

@grafitus thank you , i like it :)

Can you be more help there for translate ?

grafitus

I'll re-PM you in next days, about your huge database. :P

Advertisement: