downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

MongoGridFS::get> <MongoGridFS::find
[edit] Last updated: Fri, 24 May 2013

view this page in

MongoGridFS::findOne

(PECL mongo >=0.9.0)

MongoGridFS::findOneReturns a single file matching the criteria

Description

public MongoGridFSFile MongoGridFS::findOne ([ mixed $query = array() [, mixed $fields = array() ]] )

Parameters

query

The filename or criteria for which to search.

Return Values

Returns a MongoGridFSFile or NULL.

Examples

Example #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.

The above example will output something similar to:

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
        )

)


add a note add a note User Contributed Notes MongoGridFS::findOne - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites