mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
trying again
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@277706 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
d6c3010661
commit
cdf45f1736
2 changed files with 79 additions and 51 deletions
|
@ -1,18 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
|
||||
<refentry xml:id="mongocode.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refentry xml:id="mongoid.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>MongoCode::__construct</refname>
|
||||
<refpurpose>Creates a new code object</refpurpose>
|
||||
<refname>MongoId::__construct</refname>
|
||||
<refpurpose>Creates a new id</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<methodname>MongoCode::__construct</methodname>
|
||||
<methodparam><type>string</type><parameter>code</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>array</type><parameter>scope</parameter><initializer>array()</initializer></methodparam>
|
||||
<methodname>MongoId::__construct</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>id</parameter><initializer>&null;</initializer></methodparam>
|
||||
</methodsynopsis>
|
||||
</refsect1>
|
||||
|
||||
|
@ -22,21 +21,11 @@
|
|||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<parameter>code</parameter>
|
||||
<parameter>id</parameter>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
A string of code.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<parameter>scope</parameter>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The scope to use for the code.
|
||||
A string to use as the id.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -47,39 +36,71 @@
|
|||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a new code object.
|
||||
Returns a new id.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>MongoCode::__construct</function> example</title>
|
||||
<programlisting role="php">
|
||||
<title><function>MongoId::__construct</function> example</title>
|
||||
<para>This example shows how to create a new id. This is seldom necessary, as the driver adds an id to arrays automatically before storing them in the database.</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$code = new MongoCode('function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }', array("x" => 4));
|
||||
var_dump($code);
|
||||
$id1 = new MongoId();
|
||||
echo "$id1\n";
|
||||
|
||||
?>
|
||||
$id1 = new MongoId();
|
||||
echo "$id2\n";
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(MongoCode)#1 (2) {
|
||||
["scope"]=>
|
||||
array(1) {
|
||||
["x"]=>
|
||||
int(4)
|
||||
}
|
||||
["code"]=>
|
||||
string(80) "function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }"
|
||||
}
|
||||
49a7011a05c677b9a916612a
|
||||
49a702d5450046d3d515d10d
|
||||
]]>
|
||||
</screen>
|
||||
</screen>
|
||||
<para>
|
||||
Note that the second hexidecimal number is greater than the first.
|
||||
</para>
|
||||
</example>
|
||||
<example>
|
||||
<title>Parameter example</title>
|
||||
<para>This example shows how to use a string parameter to initialize a MongoId with a given value.</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$id1 = new MongoId();
|
||||
|
||||
// create a new id from $id1
|
||||
$id2 = new MongoId("$id1");
|
||||
|
||||
// show that $id1 and $id2 have the same hexidecimal value
|
||||
var_dump($id1 == $id2);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>MongoId::__toString</methodname></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
|
||||
<refentry xml:id="mongocode.tostring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refentry xml:id="mongoid.tostring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>MongoCode::__toString</refname>
|
||||
<refpurpose>Returns this code as a string</refpurpose>
|
||||
<refname>MongoId::__toString</refname>
|
||||
<refpurpose>Returns a hexidecimal representation of this id</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>string</type><methodname>MongoCode::__toString</methodname>
|
||||
<modifier>public</modifier> <type>string</type><methodname>MongoId::__toString</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</refsect1>
|
||||
|
@ -23,32 +23,39 @@
|
|||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
This code, the scope is not returned.
|
||||
This id.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>MongoCode::__toString</function> example</title>
|
||||
<title><function>MongoId::__toString</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$obj = array( "x" => "y" );
|
||||
|
||||
$code = new MongoCode('return x;', array("x"=>"hi"));
|
||||
echo "$code\n";
|
||||
$m = new Mongo();
|
||||
$collection = $m->selectDB("foo")->selectCollection("bar");
|
||||
|
||||
$code = new MongoCode('function() { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } }');
|
||||
echo "$code\n";
|
||||
$collection->insert($obj);
|
||||
$collection->insert($obj);
|
||||
|
||||
$cursor = $collection->find();
|
||||
$r1 = cursor->next();
|
||||
$r2 = cursor->next();
|
||||
|
||||
echo $r1["_id"] . "\n";
|
||||
echo $r2["_id"] . "\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
return x;
|
||||
function() { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } }
|
||||
49a7011a05c677b9a916612a
|
||||
49a702d5450046d3d515d10d
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue