/** * 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; }
/** * 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; }