install.def.php Question

Posts from previous Beta sessions

install.def.php Question

Postby poetter » Mon Sep 24, 2007 4:01 am

Hi,

i want to use the upgrade function to add some new configs or buttons.
a second upgrade with the same buttons or configs will leed to mysql dup primary key error.

as i don't know from which version someone is updating i need to know if the configvar, button or table all ready exists. Is there a way to get this info?
Image
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg

install.def.php Question

Postby zanix » Mon Sep 24, 2007 7:52 am

http://www.wowroster.net/MediaWiki/AddonSDK#AddOn_Install_Class_Methods
upgrade($oldversion)

Here you can add all queries for an upgrade.

$oldversion, the version you are upgrading from.

Return true on success, false on failure.


Using version_compare() you can write blocks to upgrade from certain versions with the oldest upgrade first, then the next blocks can catch older versions and upgrade them incrementally

Code: Select all
if( version_compare('2.0.6.2'$oldversion,'>') == true )
{
    
// Some stuff
}

if( 
version_compare('2.0.6.4'$oldversion,'>') == true )
{
    
// Some more stuff
}

if( 
version_compare('3.0.0.0'$oldversion,'>') == true )
{
    
// Again with the stuff


So with this we can upgrade versions 2.0.0.0 all the way up to 3.0.0.0

Also, do not worry about trying to upgrade your version number in the upgrade block, change your installer class variables to update ti
$version, $icon, $fullname, $description, $credits will all be updated to whatever you have them during the upgrade
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

install.def.php Question

Postby poetter » Mon Sep 24, 2007 3:43 pm

thx for info
Image
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg


Return to Archived

Who is online

Users browsing this forum: No registered users and 0 guests

cron