示例#1
0
 /**
  * @param Collection $collection
  * @param bool|false $prefix
  *
  * @return array
  */
 protected function getConditionArray(Collection $collection, $prefix = false)
 {
     $condition = $collection->getCondition();
     if (!is_array($condition)) {
         $condition = ['_id' => $this->createObjectId($condition)];
     }
     if ($prefix) {
         $condition = static::prefixArrayKeys($condition, $collection->getName() . '.');
     }
     return $condition;
 }
示例#2
0
 protected function fetchSingle(Collection $collection, $statement)
 {
     $name = $collection->getName();
     $entityName = $name;
     $row = $this->driver->fetch($statement);
     if (!$row) {
         return false;
     }
     if ($this->typable($collection)) {
         $entityName = $row->{$this->getType($collection)};
     }
     $entities = new SplObjectStorage();
     $entities[$this->transformSingleRow($row, $entityName)] = $collection;
     return $entities;
 }
示例#3
0
 protected function fetchSingle(Collection $collection, PDOStatement $statement)
 {
     $name = $collection->getName();
     $entityName = $name;
     $row = $statement->fetch(PDO::FETCH_OBJ);
     if (!$row) {
         return false;
     }
     if ($this->typable($collection)) {
         $entityName = $this->inferGet($row, $this->getType($collection));
     }
     $entities = new SplObjectStorage();
     $entities[$this->transformSingleRow($row, $entityName)] = $collection;
     return $entities;
 }