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

search for in the

MongoGridFSFile::getSize> <MongoGridFSFile::getFilename
[edit] Last updated: Fri, 24 May 2013

view this page in

MongoGridFSFile::getResource

(PECL mongo >=1.3.0)

MongoGridFSFile::getResourceReturns a resource that can be used to read the stored file

Description

public stream MongoGridFSFile::getResource ( void )

This method returns a stream resource that can be used with all file functions in PHP. The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.

At most two GridFSFile chunks will be loaded in memory.

Parameters

This function has no parameters.

Return Values

Returns a resource that can be used to read the file with

Examples

Example #1 MongoGridFSFile::getResource() example

<?php
$m 
= new Mongo;
$images $m->my_db->getGridFS('images');

$image $images->findOne('mongo.png');

header('Content-type: image/png;');
$stream $image->getResource();

while (!
feof($stream)) {
    echo 
fread($stream8192);
}
?>


MongoGridFSFile::getSize> <MongoGridFSFile::getFilename
[edit] Last updated: Fri, 24 May 2013
 
add a note add a note User Contributed Notes MongoGridFSFile::getResource - [3 notes]
up
1
chuck at manchuck dot com
3 months ago
Please note that the file pointer is reset on each call to get resource
up
0
Jeremy Mikola
8 months ago
This method is implemented as of version 1.3.0-beta1.

http://pecl.php.net/package-info.php?package=mongo&version=1.3.0beta1
up
-1
Kon
10 months ago
This function is not implemented yet, as I get the following error every time I try to use this function:

PHP Fatal error:  Call to undefined method MongoGridFSFile::getResource()

I understand it says ((o version information available, might only be in SVN) at the top, but just giving people a heads up.

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