We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Does a modules version number update automatically?

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

I have been developing a new module and every time I update the version number it is not reflected in the admin until I uninstall and re-install the module.

Is this right or am I missing a core module method?

Cheers

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
17 years ago
Andrew Weaver's avatar Andrew Weaver

I’m pretty sure the version does not get updated automatically. I usually include something in the CP class’s constructor to test to see if the module’s version matches the one recorded in the database.

If it does not, then I update it and if there have been databases changes between versions, make the db changes accordingly. Something like:

class SelectedItems_CP {

    var $version        = '1.2';

    function SelectedItems_CP( $switch = TRUE )
    {
        global $IN, $DB;
    
        // Upgrade module if necessary
        $query = $DB->query( "SELECT module_version FROM exp_modules WHERE module_name = 'Selecteditems'" );
        if( $query->num_rows > 0 ) 
        {
            if( $query->row['module_version'] != $this->version )
            {
                $DB->query("UPDATE exp_modules SET module_version='".$this->version."' WHERE module_name='Selecteditems'");
            }
            if ( $query->row['module_version'] < "1.1" ) {
            // Make any database changes between 1.0 and 1.1
            }
            if ( $query->row['module_version'] < "1.2" ) {
            // Make any database changes between 1.1 and 1.2
            }
        }
...
       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Adam has it.

You can use the same process that updates the version number to make other changes as necessary (like altering a table if needed or something like that) so if someone jumps from version 1.1 to 1.6 they don’t miss any database changes that might affect them.

Jamie

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.