svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ findone.xml

From: Date: Thu, 29 Dec 2011 15:45:00 +0000
Subject: svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ findone.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9304@lists.php.net to get a copy of this message
derick Thu, 29 Dec 2011 15:45:00 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=321515 Log: Explain fields for querying and return a bit better. Also add a warning for the "$" issue and add the difference between find() and findOne(). Changed paths: U phpdoc/en/trunk/reference/mongo/mongocollection/findone.xml Modified: phpdoc/en/trunk/reference/mongo/mongocollection/findone.xml =================================================================== --- phpdoc/en/trunk/reference/mongo/mongocollection/findone.xml 2011-12-29 15:29:03 UTC (rev 321514) +++ phpdoc/en/trunk/reference/mongo/mongocollection/findone.xml 2011-12-29 15:45:00 UTC (rev 321515) @@ -14,6 +14,11 @@ <methodparam choice="opt"><type>array</type><parameter>query</parameter><initializer>array()</initializer></methodparam> <methodparam choice="opt"><type>array</type><parameter>fields</parameter><initializer>array()</initializer></methodparam> </methodsynopsis> + <para> + As opposed to <function>MongoCollection::find</function>, this method + will return only the <emphasis>first</emphasis> result from the result set, + and not a <class>MongoCursor</class> that can be iterated over. + </para> </refsect1> <refsect1 role="parameters"> @@ -26,8 +31,19 @@ </term> <listitem> <para> - The fields for which to search. + The fields for which to search. MongoDB's query language is quite + extensive. The PHP driver will in almost all cases pass the query + straight through to the server, so reading the MongoDB core docs on + <link xlink:href="&url.mongodb.dochub.find;">find</link> is a good idea. </para> + <warning> + <para> + Please make sure that for all special query operaters (starting with + <literal>$</literal>) you use single quotes so that PHP doesn't try to + replace <literal>"$exists"</literal> with the value of the variable + <literal>$exists</literal>. + </para> + </warning> </listitem> </varlistentry> <varlistentry> @@ -36,7 +52,9 @@ </term> <listitem> <para> - Fields of the results to return. + Fields of the results to return. The array is in the format + <literal>array('fieldname' => true, 'fieldname2' => true)</literal>. + The <literal>_id</literal> field is always returned. </para> </listitem> </varlistentry>

« previous php.doc.cvs (#9304) next »