Advertisement:

Author Topic: Mod Authors: SMF 2.0 Database Functions  (Read 140716 times)

Offline Akyhne

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 7,331
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #140 on: September 29, 2010, 08:35:17 AM »
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.

Oya

  • Guest
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #141 on: September 29, 2010, 09:36:31 AM »
why not use 'update' ?

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #142 on: September 29, 2010, 09:50:25 AM »
Ignore should work. Try adding an empty array before ignore.

Code: [Select]
),
array(),
'ignore'
);


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

Offline Akyhne

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 7,331
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #143 on: September 29, 2010, 09:57:25 AM »
I already tried that, and it didn't work.

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #144 on: September 29, 2010, 10:08:45 AM »
The only other difference I can see to one which works is that

Code: [Select]
$db_prefix . 'collection',
should be:

Code: [Select]
'{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

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,954
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #145 on: September 29, 2010, 10:47:14 AM »
this should work

Code: [Select]
<?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
Quote
My allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Offline Alpay

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 3,634
  • Gender: Male
  • test
    • Personal Web Page
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #146 on: September 19, 2011, 06:22:52 AM »
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 ?

Offline grafitus

  • SMF Hero
  • ******
  • Posts: 3,034
    • beratdogan on GitHub
    • beratdogan on LinkedIn
    • @beratdgan on Twitter
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #147 on: September 19, 2011, 06:55:23 AM »
@Alpay, use this:
Code: [Select]
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()
);

Offline Alpay

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 3,634
  • Gender: Male
  • test
    • Personal Web Page
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #148 on: September 19, 2011, 11:53:29 AM »
@grafitus thank you , i like it :)

Can you be more help there for translate ?

Offline grafitus

  • SMF Hero
  • ******
  • Posts: 3,034
    • beratdogan on GitHub
    • beratdogan on LinkedIn
    • @beratdgan on Twitter
Re: Mod Authors: SMF 2.0 Database Functions
« Reply #149 on: September 20, 2011, 03:57:49 PM »
I'll re-PM you in next days, about your huge database. :P