Example #1
0
 /**
  * Store factory
  * @param int $type - const
  * @param string $name
  * @return Store_Interface or boolean false
  */
 public static function factory($type = Store::Local, $name = 'default')
 {
     switch ($type) {
         case self::Local:
             return Store_Local::getInstance($name);
             break;
         case self::Session:
             return Store_Session::getInstance($name);
             break;
         default:
             return false;
     }
 }
Example #2
0
 /**
  * Rename database table
  *
  * @param string $newName
  *          - new table name (without prefix)
  * @return boolean
  * @throws Exception
  */
 public function renameTable($newName)
 {
     if ($this->_objectConfig->isLocked() || $this->_objectConfig->isReadOnly()) {
         $this->_errors[] = 'Can not build locked object ' . $this->_objectConfig->getName();
         return false;
     }
     $store = Store_Local::getInstance();
     $sql = 'RENAME TABLE `' . $this->_model->table() . '` TO `' . $this->_model->getDbPrefix() . $newName . '` ;';
     try {
         $this->_db->query($sql);
         $this->_logSql($sql);
         $this->_objectConfig->getConfig()->set('table', $newName);
         $this->_model->refreshTableInfo();
         return true;
     } catch (Exception $e) {
         $this->_errors[] = $e->getMessage() . ' <br>SQL: ' . $sql;
         return false;
     }
 }