Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: brianjw on March 26, 2008, 06:44:22 PM

Title: Package Server DB
Post by: brianjw on March 26, 2008, 06:44:22 PM
I am not familiar with the 2.0 database as of yet. I need to know what needs to be changed in the queries that remove and add a package server to the database from 1.1 to 2.0 Beta 3.
Here are the codes from 1.1:
Code: [Select]
   // Delete our package server if there is one.
   $request = db_query("
       DELETE FROM {$db_prefix}package_servers WHERE name = 'Gamerz Garage'", __FILE__, __LINE__);
     
   // Install our package server.
   $request = db_query("
      INSERT INTO {$db_prefix}package_servers (name,url)VALUES('Gamerz Garage','http://www.gamerzgarage.com/mods')", __FILE__, __LINE__);

Thanks,
brianjw
Title: Re: Package Server DB
Post by: karlbenson on March 26, 2008, 07:25:03 PM
Presuming you need to use 2.0 db functions see

Mod Authors: SMF 2.0 Database Functions (http://www.simplemachines.org/community/index.php?topic=224166.0)
Title: Re: Package Server DB
Post by: brianjw on March 26, 2008, 09:58:01 PM
Ok, well I can get some of it done. But I am just not very good with databases. Can someone help me finish this code?
Code: [Select]
   // Install our package server.
   $smcFunc['db_insert']('insert','
      '{db_prefix}package_servers',
     
Title: Re: Package Server DB
Post by: H on April 03, 2008, 04:25:53 PM
Hi Brianjw,

Did you manage to do this?
Title: Re: Package Server DB
Post by: brianjw on April 03, 2008, 04:43:40 PM
No, i am not good with db's... :(
Title: Re: Package Server DB
Post by: SleePy on April 10, 2008, 01:34:16 PM
Are you trying to remove the entry from the package database?
Or are you attempting to do something else?
Title: Re: Package Server DB
Post by: brianjw on April 10, 2008, 02:20:18 PM
I want to put this db query in the add_settings.php file to remove the package server named ___ if there is one and then to add a package server named ___. This way it will make it so there aren't duplicate servers. I am horrible with dbs.
Title: Re: Package Server DB
Post by: SleePy on April 19, 2008, 10:22:38 PM
Code: [Select]
$request = $smcFunc['db_insert']('replace',
    '{db_prefix}package_servers',
    array(
        'name' => 'string',
        'url' => 'string',
    ),
    array(
        'Gamerz Garage', 'http://www.gamerzgarage.com/mods',
    ),
    array( 'id_server')
);

That should do it.
It will replace the entry if it exists otherwise it will insert it.
Title: Re: Package Server DB
Post by: brianjw on April 19, 2008, 11:02:46 PM
Thanks. I will try it out later. :)