MongoGridFS::findOne
(PECL mongo >=0.9.0)
MongoGridFS::findOne — Returns a single file matching the criteria
Описание
public MongoGridFSFile MongoGridFS::findOne
([ mixed
$query
= array()
[, mixed $fields
= array()
]] )Список параметров
-
query
-
The filename or criteria for which to search.
Возвращаемые значения
Returns a MongoGridFSFile or NULL
.
Примеры
Пример #1 MongoGridFS::findOne() example
Example demonstrating how to find a single file from the MongoGridFS.
<?php
$downloads = $mongo->my_db->getGridFS('downloads');
$downloads->storeFile('filename.tgz');
$download = $downloads->findOne('filename.tgz'); // instance of MongoGridFSFile
print_r($download);
?>
See MongoGridFSFile for more information about how to work with files.
Результатом выполнения данного примера будет что-то подобное:
MongoGridFSFile Object ( [file] => Array ( [_id] => MongoId Object ( ) [filename] => filename.tgz [uploadDate] => MongoDate Object ( [sec] => 1274288014 [usec] => 467000 ) [chunkSize] => 262144 [md5] => d41d8cd98f00b204e9800998ecf8427e ) [gridfs:protected] => MongoGridFS Object ( [chunks] => MongoCollection Object ( ) [filesName:protected] => downloads.files [chunksName:protected] => downloads.chunks ) )
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- Классы GridFS
- Функция MongoGridFS::__construct() - Creates new file collections
- Функция MongoGridFS::delete() - Delete a file from the database
- Функция MongoGridFS::drop() - Drops the files and chunks collections
- Функция MongoGridFS::find() - Queries for files
- Функция MongoGridFS::findOne() - Returns a single file matching the criteria
- Функция MongoGridFS::get() - Retrieve a file from the database
- Функция MongoGridFS::put() - Stores a file in the database
- Функция MongoGridFS::remove() - Removes files from the collections
- Функция MongoGridFS::storeBytes() - Stores a string of bytes in the database
- Функция MongoGridFS::storeFile() - Stores a file in the database
- Функция MongoGridFS::storeUpload() - Stores an uploaded file in the database
Коментарии
404 Not Found