/** * Constructor with parameters * Array of arguments with keys * - 'connection' Varien_Db_Adapter_Interface * - 'metadata' Enterprise_Mview_Model_Metadata * - 'factory' Enterprise_Mview_Model_Factory * * @param array $args */ public function __construct(array $args) { $this->_setConnection($args['connection']); $this->_setMetadata($args['metadata']); $this->_setFactory($args['factory']); $this->_table = $this->_factory->getMagentoDbObjectTable($this->_connection, $this->_metadata->getTableName()); $this->_view = $this->_factory->getMagentoDbObjectView($this->_connection, $this->_metadata->getViewName()); }
/** * Refresh materialized view * * @return Enterprise_Mview_Model_Action_Mview_Refresh * @throws Exception */ public function execute() { try { $insert = $this->_connection->insertFromSelect($this->_connection->select()->from($this->_metadata->getViewName()), $this->_metadata->getTableName()); $this->_connection->delete($this->_metadata->getTableName()); $this->_connection->query($insert); $this->_metadata->setValidStatus()->setVersionId($this->_selectLastVersionId())->save(); } catch (Exception $e) { $this->_metadata->setInvalidStatus()->save(); throw $e; } return $this; }
/** * Returns select with changed rows * * @return Varien_Db_Select */ protected function _selectChangedRows() { return $this->_connection->select()->from(array('source' => $this->_metadata->getViewName()))->where($this->_metadata->getKeyColumn() . ' IN ( ' . $this->_selectChangedIds() . ' )'); }
/** * Returns select sql * * @return Varien_Db_Select */ protected function _getSelectSql() { return $this->_connection->select()->from($this->_metadata->getViewName())->where($this->_metadata->getKeyColumn() . ' = ?', $this->_keyColumnIdValue); }