Esempio n. 1
0
 /**
  * sp_Installer::install() - this method performs the installation of SubjectsPlus
  *
  * @return boolean
  */
 public function install()
 {
     $db = new Querier();
     foreach ($this->lobjCreateQueries as $lstrCQuery) {
         if ($db->exec($lstrCQuery) === FALSE) {
             var_dump($db->errorInfo());
             $this->displayInstallationErrorPage(_("Problem creating new table."));
             return FALSE;
         }
     }
     foreach ($this->lobjInsertQueries as $lstrIQuery) {
         if ($db->exec($lstrIQuery) === FALSE) {
             $this->displayInstallationErrorPage(_("Problem inserting new data into table."));
             $error_info = $db->errorInfo();
             if (count_chars($error_info[2]) > 0) {
                 var_dump($db->errorInfo());
                 echo $lstrIQuery;
             }
             return FALSE;
         }
     }
     if (!$this->updateRewriteBases()) {
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 2
0
 /**
  * sp_Updater::update() - this method updates to SubjectPlus 3.0
  *
  * @return boolean
  */
 public function update()
 {
     $db = new Querier();
     $lstrVersion = $this->getCurrentVersion();
     switch ($lstrVersion) {
         case '1':
             foreach ($this->lobj1NewTables as $lstrNQuery) {
                 if ($db->query($lstrNQuery) === FALSE) {
                     $this->displayUpdaterErrorPage(_("Problem creating new table.") . "<br />{$lstrNQuery}");
                     return FALSE;
                 }
             }
             foreach ($this->lobj1InsertInto as $lstrIQuery) {
                 if ($db->query($lstrIQuery) === FALSE) {
                     $this->displayUpdaterErrorPage(_("Problem inserting new data into table.") . "<br />{$lstrIQuery}");
                     return FALSE;
                 }
             }
             if (!$this->fix1ExistingData()) {
                 return FALSE;
             }
             if (!$this->before1AlterQueries()) {
                 return FALSE;
             }
             foreach ($this->lobj1AlterTables as $lstrAQuery) {
                 if ($db->exec($lstrAQuery) === FALSE) {
                     //if rss doesn't exist, keep going. assume correct column
                     $lobjDBErrorInfo = $db->errorInfo();
                     if ($lobjDBErrorInfo[2] == 'Can\'t DROP \'rss\'; check that column/key exists') {
                         continue;
                     }
                     $this->displayUpdaterErrorPage(_("Problem altering existing tables.") . "<br />{$lstrAQuery}");
                     return FALSE;
                 }
             }
             if (!$this->after1AlterQueries()) {
                 return FALSE;
             }
         case '2':
             foreach ($this->lobj2NewTables as $lstrNQuery) {
                 if ($db->query($lstrNQuery) === FALSE) {
                     $this->displayUpdaterErrorPage(_("Problem creating new table.") . "<br />{$lstrNQuery}");
                     return FALSE;
                 }
             }
             foreach ($this->lobj2InsertInto as $lstrIQuery) {
                 if ($db->query($lstrIQuery) === FALSE) {
                     $this->displayUpdaterErrorPage(_("Problem inserting new data into table.") . "<br />{$lstrIQuery}");
                     return FALSE;
                 }
             }
             if (!$this->fix2ExistingData()) {
                 return FALSE;
             }
             foreach ($this->lobj2AlterTables as $lstrAQuery) {
                 if ($db->exec($lstrAQuery) === FALSE) {
                     //if duplicate column, keep going. assume correct column
                     $lobjDBErrorInfo = $db->errorInfo();
                     if ($lobjDBErrorInfo[1] == '1060') {
                         continue;
                     }
                     $this->displayUpdaterErrorPage(_("Problem altering existing tables.") . "<br />{$lstrAQuery}");
                     return FALSE;
                 }
             }
         default:
             break;
     }
     if (!$this->updateRewriteBases()) {
         return FALSE;
     }
     return TRUE;
 }