php-doc-en/reference/mongo/mongogridfsfile/getresource.xml
TAKAGI Masahiro 6edc9029fb set svn:keywords and svn:eol-style
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322890 c90b9560-bf6c-de11-be94-00142212c4b1
2012-01-28 00:08:25 +00:00

81 lines
2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongogridfsfile.getresource" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoGridFSFile::getResource</refname>
<refpurpose>Returns a resource that can be used to read the stored file</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>stream</type><methodname>MongoGridFSFile::getResource</methodname>
<void/>
</methodsynopsis>
<para>
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.
</para>
<para>
At most two GridFSFile chunks will be loaded in memory.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a resource that can be used to read the file with
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><methodname>MongoGridFSFile::getResource</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?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($stream, 8192);
}
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->