/** * @return \MongoDB\Driver\Cursor */ protected function ensureCursor() { if ($this->cursor === null) { $this->cursor = $this->db->command(TypeConverter::convertLegacyArrayToObject($this->command), $this->getOptions()); } return $this->cursor; }
/** * Querys this collection, returning a single element * @link http://www.php.net/manual/en/mongocollection.findone.php * @param array $query The fields for which to search. * @param array $fields Fields of the results to return. * @return array|null */ public function findOne(array $query = array(), array $fields = array()) { $document = $this->collection->findOne(TypeConverter::convertLegacyArrayToObject($query), ['projection' => $fields]); if ($document !== null) { $document = TypeConverter::convertObjectToLegacyArray($document); } return $document; }