コード例 #1
0
 protected function findMostRecent(array $queries)
 {
     // SELECT MAX( rev_id ) AS rev_id
     // FROM flow_tree_revision
     // WHERE rev_type= 'post' AND rev_type_id IN (...)
     // GROUP BY rev_type_id
     $duplicator = new ResultDuplicator(array('rev_type_id'), 1);
     foreach ($queries as $idx => $query) {
         $query = UUID::convertUUIDs((array) $query, 'alphadecimal');
         $duplicator->add($query, $idx);
     }
     $dbr = $this->dbFactory->getDB(DB_MASTER);
     $res = $dbr->select(array('flow_revision'), array('rev_id' => "MAX( 'rev_id' )"), array('rev_type' => $this->getRevType()) + $this->preprocessSqlArray($this->buildCompositeInCondition($dbr, $duplicator->getUniqueQueries())), __METHOD__, array('GROUP BY' => 'rev_type_id'));
     if (!$res) {
         // TODO: dont fail, but dont end up caching bad result either
         throw new DataModelException('query failure', 'process-data');
     }
     $revisionIds = array();
     foreach ($res as $row) {
         $revisionIds[] = $row->rev_id;
     }
     // Due to the grouping and max, we cant reliably get a full
     // columns info in the above query, forcing the join below
     // rather than just querying flow_revision.
     return $this->findRevIdReal($duplicator, $revisionIds);
 }