mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@328585 c90b9560-bf6c-de11-be94-00142212c4b1
131 lines
3.1 KiB
XML
131 lines
3.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: c6e47f5c4b38ebd19a9a121bee31edc051bcc433 Maintainer: chuso Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
|
|
<refentry xml:id="mongocode.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>MongoCode::__construct</refname>
|
|
<refpurpose>Crea un nuevo objeto de código</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <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>
|
|
</methodsynopsis>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>code</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Texto del código.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>scope</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Ámbito que se usará para este código.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve un nuevo objeto de código.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title>Ejemplo de <methodname>MongoCode::__construct</methodname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$code = new MongoCode('function() { '.
|
|
'for(i=0;i<10;i++) {'.
|
|
'db.foo.update({z : i}, {z : x});'.
|
|
'}'.
|
|
'return x-1;'.
|
|
'}', array("x" => 4));
|
|
var_dump($code);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
object(MongoCode)#1 (2) {
|
|
["scope"]=>
|
|
array(1) {
|
|
["x"]=>
|
|
int(4)
|
|
}
|
|
["code"]=>
|
|
string(80) "function() { for(i=0;i<10;i++) { db.foo.update({z : i}, {z : x}); } return x-1; }"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
|
|
<example>
|
|
<title>Usando <classname>MongoCode</classname> con $where</title>
|
|
<para>
|
|
Este ejemplo consulta la colección de elementos cuyos campos 'x' valgan menos que $y. Tenga en cuenta
|
|
que se pasan objetos PHP al ámbito de JavaScript y que la función JavaScript devuelve un booleano.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$cursor = $collection->find(array('$where' => new MongoCode('function() { return this.x < y; }', array('y'=>$y))));
|
|
|
|
?>
|
|
]]>
|
|
</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
|
|
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
|
|
-->
|