/**
  * Refresh rows by ids from changelog
  *
  * @return Enterprise_Mview_Model_Action_Mview_Refresh_Changelog
  * @throws Enterprise_Mview_Exception
  */
 public function execute()
 {
     $this->_validate();
     $this->_connection->beginTransaction();
     try {
         $this->_connection->delete($this->_metadata->getTableName(), array($this->_metadata->getKeyColumn() . ' IN ( ' . $this->_selectChangedIds() . ' )'));
         $this->_connection->query($this->_connection->insertFromSelect($this->_selectChangedRows(), $this->_metadata->getTableName()));
         $this->_metadata->setVersionId($this->_selectLastVersionId());
         $this->_metadata->save();
         $this->_connection->commit();
     } catch (Exception $e) {
         $this->_connection->rollBack();
         $this->_metadata->setOutOfDateStatus()->save();
         throw new Enterprise_Mview_Exception($e->getMessage(), $e->getCode());
     }
     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;
 }