mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
mongodb examples
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@296294 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
00853e467c
commit
968a1e10ed
2 changed files with 40 additions and 2 deletions
|
@ -18,12 +18,14 @@
|
|||
There's a command for that. Need to turn up logging? You get the idea.
|
||||
</para>
|
||||
<para>
|
||||
This method is identical to running:
|
||||
This method is identical to the function:
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$db->selectCollection('$cmd')->findOne($data);
|
||||
public function command($data) {
|
||||
return $this->selectCollection('$cmd')->findOne($data);
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -14,6 +14,42 @@
|
|||
<methodparam><type>Mongo</type><parameter>conn</parameter></methodparam>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
This method is not meant to be called directly. The preferred way to create
|
||||
an instance of MongoDB is through <function>Mongo::__get</function> or
|
||||
<function>Mongo::selectDB</function>.
|
||||
</para>
|
||||
<para>
|
||||
If you're ignoring the previous paragraph and want to call it directly you
|
||||
can do so:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$m = new Mongo();
|
||||
$db = new MongoDB($m, 'mydbname');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
But don't. Isn't this much nicer:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$m = new Mongo();
|
||||
$db = $m->mydbname;
|
||||
|
||||
// or, if the name contains weird characters:
|
||||
|
||||
$db = $m->selectDB('my,db:name');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
|
|
Loading…
Reference in a new issue