name_install_addon()


This function is used to add new database tables or to modify existing OR tables and data when necessary. This should be used at a minimum to store the version number of your add-on in the add-ons table and compare the add-on version to the previously installed version (if any) and determine if an installation or an update is needed and then carry out any required database modifications.


An example of a valid function:

function name_install_addon(){

    $current_version = "1";

       global $conn, $config;

       require_once($config['basepath'].'/include/misc.inc.php');

    $misc = new Misc();

       //Check Current Installed Version

    $sql = 'SELECT addons_version FROM '.$config['table_prefix_no_lang'].'addons

            WHERE addons_name = \'name\'';

    $recordSet = $conn->Execute($sql);

    $version = $recordSet->fields[0];

       if ($version == ){

               // Preform a new install. Create any database tables, insert version # into addons table.

        $sql = 'INSERT INTO '.$config['table_prefix_no_lang'].'addons

               (addons_version, addons_name)

                VALUES (\'1\',\'name\')';

        $recordSet = $conn->Execute($sql);

               return TRUE;

    }

       elseif($version != $current_version) {

               //Preform Updates to database based on previous installed version.

               switch($version){

                       case '0';

                       break;

        } // switch

               return TRUE;

    }

       return FALSE;

}

?>