/** * @param array $cached * @param array $keyToQuery * @return ResultDuplicator */ public function getResultDuplicator(array $cached, array $keyToQuery) { $results = $this->inner->expandCacheResult($cached, $keyToQuery); // Allows us to flatten $results into a single $query array, then // rebuild final return value in same structure and order as $results. $duplicator = new ResultDuplicator($this->shallow->getPrimaryKeyColumns(), 2); foreach ($results as $i => $rows) { foreach ($rows as $j => $row) { $duplicator->add($row, array($i, $j)); } } return $duplicator; }
/** * @param ResultDuplicator $duplicator * @param array $revisionIds Binary strings representing revision uuid's * @return array * @throws DataModelException */ protected function findRevIdReal(ResultDuplicator $duplicator, array $revisionIds) { if ($revisionIds) { // SELECT * from flow_revision // JOIN flow_tree_revision ON tree_rev_id = rev_id // WHERE rev_id IN (...) $dbr = $this->dbFactory->getDB(DB_MASTER); $tables = array('flow_revision'); $joins = array(); if ($this->joinTable()) { $tables['rev'] = $this->joinTable(); $joins = array('rev' => array('JOIN', "rev_id = " . $this->joinField())); } $res = $dbr->select($tables, '*', array('rev_id' => $revisionIds), __METHOD__, array(), $joins); if (!$res) { // TODO: dont fail, but dont end up caching bad result either throw new DataModelException('query failure', 'process-data'); } foreach ($res as $row) { $row = UUID::convertUUIDs((array) $row, 'alphadecimal'); $duplicator->merge($row, array($row)); } } return $duplicator->getResult(); }