/** * Return result set for current query */ public function toCollection(\Spot\Query $query, $stmt) { $mapper = $query->mapper(); $entityClass = $query->entityName(); if ($stmt instanceof \PDOStatement) { // Set PDO fetch mode $stmt->setFetchMode(\PDO::FETCH_ASSOC); $collection = $mapper->collection($entityClass, $stmt, $query->with()); // Ensure statement is closed $stmt->closeCursor(); return $collection; } else { $mapper->addError(__METHOD__ . " - Unable to execute query " . implode(' | ', $this->connection()->errorInfo())); return array(); } }
/** * Return result set for current query */ public function toCollection(\Spot\Query $query, \MongoCursor $cursor) { $mapper = $query->mapper(); $entityClass = $query->entityName(); if ($cursor instanceof MongoCursor) { // Set timeout if (isset($this->options['cursor']['timeout']) && is_int($this->options['cursor']['timeout'])) { $cursor->timeout($this->options['cursor']['timeout']); } return $mapper->collection($entityClass, $cursor); } else { $mapper->addError(__METHOD__ . " - Unable to execute query - not a valid MongoCursor"); return array(); } }