findOne() публичный Метод

Returns a single file matching the criteria
public findOne ( mixed $query = [], array $fields = [], array $options = [] ) : MongoGridFSFile | null
$query mixed The fields for which to search or a filename to search for.
$fields array Fields of the results to return.
$options array Options for the find command
Результат MongoGridFSFile | null
Пример #1
0
 /**
  */
 protected function _getFile($path, $name)
 {
     $query = array($this->_mdKey(self::FNAME) => $name, $this->_mdKey(self::PATH) => $this->_convertPath($path));
     try {
         return $this->_files->findOne($query);
     } catch (MongoException $e) {
         throw new Horde_Vfs_Exception($e);
     }
 }
Пример #2
0
 /**
  * @param \MongoGridFS $gridFs
  */
 function it_should_calculate_checksum($gridFs)
 {
     $someFile = new \stdClass();
     $someFile->file = array('md5' => 'md5123');
     $gridFs->findOne('filename', array('md5'))->willReturn($someFile);
     $this->checksum('filename')->shouldReturn('md5123');
 }
 protected function getFile($path)
 {
     $file = $this->db->findOne(array("filename" => $this->_basename($path), "metadata.path" => $this->_dirname($path)));
     return $file;
 }