示例#1
0
 /**
  * Create materialized view
  *
  * @return Mage_Mview_Model_Command_Create|mixed
  * @throws Exception
  * @throws Exception
  */
 public function execute()
 {
     if (!$this->_mview->isExists() || $this->_changelog->isExists()) {
         throw new Exception('Mview does not exists or changelog with same name already exists!!!');
     }
     $describe = $this->_mview->describe();
     $column = $describe[$this->_ruleColumn];
     $table = $this->_connection->newTable()->addColumn($this->_ruleColumn, $column['DATA_TYPE'], implode(',', array($column['LENGTH'], $column['SCALE'], $column['PRECISION'])), array('unsigned' => $column['UNSIGNED'], 'nullable' => false, 'primary' => true), 'Id')->setComment(sprintf('Changelog for table `%s`', $this->_mview->getName()));
     $this->_changelog->create($table);
     return $this;
 }
示例#2
0
 /**
  * Create materialized view
  *
  * @return Mage_Mview_Model_Command_Create|mixed
  * @throws Exception
  * @throws Exception
  */
 public function execute()
 {
     if ($this->_table->isExists() || $this->_view->isExists()) {
         throw new Exception('Table or view with same name already exists!!!');
     }
     try {
         $this->_view->createFromSource($this->_select);
         $this->_table->createFromSource($this->_view->getName());
     } catch (Exception $e) {
         $this->_table->drop();
         $this->_view->drop();
         throw $e;
     }
     return $this;
 }
 /**
  * Checks whether materialized view table exists.
  *
  * @return Enterprise_Mview_Model_Action_Changelog_Create
  * @throws Enterprise_Mview_Exception
  */
 public function validate()
 {
     if (!$this->_table->isExists()) {
         throw new Enterprise_Mview_Exception('Mview table does not exist');
     }
     if (!$this->_metadata->getKeyColumn()) {
         throw new Enterprise_Mview_Exception('Key Column is required field');
     }
     return $this;
 }
 /**
  * Create view and mview table
  * 1) Create view;
  * 2) Create table;
  * 3) Update view name and status in metadata.
  *
  * @return Enterprise_Mview_Model_Action_Mview_Create
  * @throws Exception
  */
 public function execute()
 {
     try {
         if (!$this->_view->isExists()) {
             $this->_view->createFromSource($this->_select);
         }
         if (!$this->_table->isExists()) {
             $select = $this->_connection->select()->from($this->_view->getObjectName());
             $this->_table->createFromSource($select);
         }
         $this->_metadata->setViewName($this->_view->getObjectName());
         $this->_metadata->setValidStatus();
         $this->_metadata->save();
     } catch (Exception $e) {
         $this->_view->drop();
         $this->_table->drop();
         throw $e;
     }
     return $this;
 }