コード例 #1
0
ファイル: Finder.php プロジェクト: astar3086/studio_logistic
 /**
  * Do not call this method. This method is used internally to perform the relational query
  * based on the given DB criteria.
  * @param \Database\schema\Criteria $criteria the DB criteria
  * @param boolean $all whether to bring back all records
  * @return mixed the query result
  */
 public function query($criteria, $all = false)
 {
     $this->joinAll = $criteria->together === true;
     if ($criteria->alias != '') {
         $this->_joinTree->tableAlias = $criteria->alias;
         $this->_joinTree->rawTableAlias = $this->_builder->getSchema()->quoteTableName($criteria->alias);
     }
     $this->_joinTree->find($criteria);
     $this->_joinTree->afterFind();
     if ($all) {
         $result = array_values($this->_joinTree->records);
         if ($criteria->index !== null) {
             $index = $criteria->index;
             $array = [];
             foreach ($result as $object) {
                 $array[$object->{$index}] = $object;
             }
             $result = $array;
         }
     } elseif (count($this->_joinTree->records)) {
         $result = reset($this->_joinTree->records);
     } else {
         $result = null;
     }
     $this->destroyJoinTree();
     return $result;
 }