/** * Load changelog by metadata * * @param null|int $currentVersion * @return array */ public function loadByMetadata($currentVersion = null) { $select = $this->_connection->select()->from(array('changelog' => $this->_metadata->getChangelogName()), array())->where('version_id >= ?', $this->_metadata->getVersionId())->columns(array($this->_metadata->getKeyColumn())); if ($currentVersion) { $select->where('version_id < ?', $currentVersion); } return $this->_connection->fetchCol($select); }
/** * Clean duplicate entity data from changelog tables before running the indexing * * @param Enterprise_Mview_Model_Metadata $metadata * @return Enterprise_Mview_Model_Client */ protected function _cleanChangelogTablesBeforeIndexing(Enterprise_Mview_Model_Metadata $metadata) { $_connection = $this->_getDefaultConnection(); $subSelect = $_connection->select()->from(array('cl' => $metadata->getChangelogName()), array('version_id' => 'MAX(cl.version_id)'))->where('cl.version_id > ?', $metadata->getVersionId())->group('cl.' . $metadata->getKeyColumn()); $select = $_connection->select()->from($subSelect, array('*')); $whereCondition = array($_connection->quoteInto('version_id > ?', $metadata->getVersionId()), 'version_id NOT IN (' . $select . ')'); $_connection->delete($metadata->getChangelogName(), implode(' AND ', $whereCondition)); return $this; }
/** * Returns select object with changed Ids * * @param int|null $maxVersion * @return Varien_Db_Select */ protected function _getChangedIdsSelect($maxVersion = null) { if (empty($maxVersion)) { $maxVersion = $this->_getCurrentVersionId(); } return $this->_connection->select()->from($this->_metadata->getChangelogName(), array())->where('version_id > ?', $this->_metadata->getVersionId())->where('version_id <= ?', $maxVersion)->columns(array($this->_metadata->getKeyColumn()))->distinct(); }
/** * Clear changelog table * * @return Enterprise_Mview_Model_Action_Changelog_Clear */ public function execute() { $this->_connection->delete($this->_metadata->getChangelogName(), array('version_id < ?' => $this->_metadata->getVersionId())); return $this; }
/** * Returns select object with changed Ids * * @return Varien_Db_Select */ protected function _selectChangedIds() { return $this->_connection->select()->from(array('changelog' => $this->_metadata->getChangelogName(), array()))->where('version_id >= ?', $this->_metadata->getVersionId())->columns(array($this->_metadata->getKeyColumn())); }