php-doc-en/reference/mongo/mongodb.xml
Jakub Vrana 5e240161c1 Link class members
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322123 c90b9560-bf6c-de11-be94-00142212c4b1
2012-01-12 06:15:07 +00:00

223 lines
7.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongodb" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoDB class</title>
<titleabbrev>MongoDB</titleabbrev>
<partintro>
<!-- {{{ Mongodb intro -->
<section xml:id="mongodb.intro">
&reftitle.intro;
<para>
Instances of this class are used to interact with a database. To get a
database:
<programlisting role="php">
<![CDATA[
<?php
$m = new Mongo(); // connect
$db = $m->selectDB("example");
?>
]]>
</programlisting>
Database names can use almost any character in the ASCII range. However,
they cannot contain &quot; &quot;, &quot;.&quot; or be the empty string.
The name "system" is also reserved.
</para>
<para>
A few unusual, but valid, database names: &quot;null&quot;, &quot;[x,y]&quot;, &quot;3&quot;, &quot;\&quot;&quot;, &quot;/&quot;.
</para>
<para>
Unlike collection names, database names may contain &quot;$&quot;.
</para>
</section>
<!-- }}} -->
<section xml:id="mongodb.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoDB</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoDB</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
<fieldsynopsis>
<modifier>const</modifier>
<type>int</type>
<varname linkend="mongodb.constants.profilingoff">MongoDB::PROFILING_OFF</varname>
<initializer>0</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>int</type>
<varname linkend="mongodb.constants.profilingslow">MongoDB::PROFILING_SLOW</varname>
<initializer>1</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>int</type>
<varname linkend="mongodb.constants.profilingon">MongoDB::PROFILING_ON</varname>
<initializer>2</initializer>
</fieldsynopsis>
<classsynopsisinfo role="comment">Fields</classsynopsisinfo>
<fieldsynopsis>
<modifier>public</modifier>
<type>integer</type>
<varname linkend="mongodb.props.w">w</varname>
<initializer>1</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>public</modifier>
<type>integer</type>
<varname linkend="mongodb.props.wtimeout">wtimeout</varname>
<initializer>10000</initializer>
</fieldsynopsis>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<!-- }}} -->
</section>
<section>
&reftitle.constants;
<section xml:id="mongodb.constants.types">
<title>MongoDB Log Levels</title>
<variablelist>
<varlistentry xml:id="mongodb.constants.profilingoff">
<term><constant>MongoDB::PROFILING_OFF</constant></term>
<term><constant>0</constant></term>
<listitem>
<simpara>
Profiling is off.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb.constants.profilingslow">
<term><constant>MongoDB::PROFILING_SLOW</constant></term>
<term><constant>1</constant></term>
<listitem>
<simpara>
Profiling is on for slow operations (&gt;100 ms).
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb.constants.profilingon">
<term><constant>MongoDB::PROFILING_ON</constant></term>
<term><constant>2</constant></term>
<listitem>
<simpara>
Profiling is on for all operations.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</section>
</section>
<section>
<title>Fields</title>
<variablelist>
<varlistentry xml:id="mongodb.props.w">
<term><varname>w</varname></term>
<term>1</term>
<listitem>
<para>
The number of servers to replicate a change to before returning success.
Inherited by instances of <classname>MongoCollection</classname> derived
from this. <literal>w</literal> functionality is only available in
version 1.5.1+ of the MongoDB server and 1.0.8+ of the driver.
</para>
<para>
<literal>w</literal> is used whenever you perform a "safe" operation
(<function>MongoCollection::insert</function>,
<function>MongoCollection::update</function>,
<function>MongoCollection::remove</function>,
<function>MongoCollection::save</function>, and
<function>MongoCollection::ensureIndex</function> all support safe
options). With the default value (1), a safe operation will return once
the database server has the operation. If the server goes down before
the operation has been replicated to a slave, it is possible to lose the
operation forever. Thus, you can specify <literal>w</literal> to be
higher than one and guarantee that at least one slave has the operation
before it is considered successful.
</para>
<para>
For example, if <literal>w</literal> is 2, the main server and one slave
must have a record of the operation or the driver will throw a
<classname>MongoCursorException</classname>. It is tempting to set
<literal>w</literal> to the total number of slaves + master, but then if
one slave is down the op will fail and an exception will be thrown, so
usually <literal>w=2</literal> is safest (master+1 slave).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb.props.wtimeout">
<term><varname>wtimeout</varname></term>
<term>10000</term>
<listitem>
<para>
The number of milliseconds to wait for <literal>MongoDB::$w</literal>
replications to take place. Inherited by instances of
<classname>MongoCollection</classname> derived from this.
<literal>w</literal> functionality is only available in version 1.5.1+ of
the MongoDB server and 1.0.8+ of the driver.
</para>
<para>
Unless <literal>wtimeout</literal> is set, the server waits forever for
replicating to <literal>w</literal> servers to finish. The driver
defaults to waiting for 10 seconds, you can change this value to alter
its behavior.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section>
&reftitle.seealso;
<para>
MongoDB core docs on <link xlink:href="&url.mongodb.dochub.databases;">databases</link>.
</para>
</section>
</partintro>
&reference.mongo.entities.mongodb;
</phpdoc:classref>
<!-- 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
indent-tabs-mode:nil
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
-->