function update() { if (!$this->db->connect()) { return $this->returnJSON(false, "Could not connect to database " . $this->db->getError()); } if (!$this->db->selectSchema()) { return $this->returnJSON(false, "Could not open database schema '" . MYSQL_DATABASE . "'"); } $updater = new installer($this->db); include "../modules/bms/version.php"; $newVersion = $modules["bms"]["version"]; $currentVersion = $this->currentVersion; //next we loop through each upgrade process while ($currentVersion != $newVersion) { switch ($currentVersion) { // ================================================================================================ case 0.8: $version = 0.9; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; // ================================================================================================ // ================================================================================================ case 0.9: $version = 0.92; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; // ================================================================================================ // ================================================================================================ case 0.92: $version = 0.9399999999999999; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; // ================================================================================================ // ================================================================================================ case 0.9399999999999999: $version = 0.96; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } if (!$this->v096updateInvoiceAddresses()) { return $this->returnJSON(false, "v0.96 Invoice Addresses Movement Failed"); } if (!$this->v096transferClientAddresses()) { return $this->returnJSON(false, "v0.96 Client Addresses Movement Failed"); } //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; // ================================================================================================ // ================================================================================================ case 0.96: $version = 0.98; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Create first posting session record $this->v098UpdatePostingSession(); //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; // ================================================================================================ // ================================================================================================ case 0.98: $version = 0.99; //Processing Data Structure Changes $thereturn = $updater->processSQLfile("../modules/bms/install/updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Updating Module Table $thereturn = $this->updateModuleVersion("bms", $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } $currentVersion = $version; break; } //endswitch currentVersion } //endwhile currentversion/newversion return $this->returnJSON(true, "Module '" . $this->moduleName . "' Updated"); }
function update() { if (!$this->db->connect()) { return $this->returnJSON(false, "Could not connect to database " . $this->db->getError()); } if (!$this->db->selectSchema()) { return $this->returnJSON(false, "Could not open database schema '" . MYSQL_DATABASE . "'"); } $updater = new installer($this->db); //next we loop through each upgrade process foreach ($this->updateVersions as $version) { if ($this->currentVersion <= $version) { $thereturn = $updater->processSQLfile($this->pathToModule . "updatev" . $version . ".sql"); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } //Updating Module Table $thereturn = $this->updateModuleVersion($this->moduleName, $version); if ($thereturn !== true) { return $this->returnJSON(false, $thereturn); } } //endif } //endforeach return $this->returnJSON(true, "Module '" . $this->moduleName . "' Updated"); }
function install() { if (!$this->db->connect()) { return $this->returnJSON(false, "Could not connect to database " . $this->db->getError()); } if (!$this->db->selectSchema()) { return $this->returnJSON(false, "Could not open database schema '" . MYSQL_DATABASE . "'"); } $installer = new installer($this->db); //Run create table sql file ocreate the tables if (file_exists($this->pathToModule . $this->createTablesSQL)) { $tempReturn = $installer->processSQLfile($this->pathToModule . $this->createTablesSQL); if ($tempReturn !== true) { return $this->returnJSON(false, $tempReturn); } } //end if $thereturn = ""; //now we run the import for each file foreach ($this->tables as $table) { $tempReturn = $installer->processSQLFile($this->pathToModule . $table . ".sql"); if ($tempReturn !== true) { $thereturn .= $tempReturn; } } //end foreach if ($thereturn) { return $this->returnJSON(false, $thereturn); } else { return $this->returnJSON(true, "Module Installed"); } }