2015-03-24 18:15:02 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2015-03-30 12:56:33 +00:00
|
|
|
<!-- $Revision$ -->
|
2015-03-24 18:15:02 +00:00
|
|
|
|
2015-09-23 15:35:13 +00:00
|
|
|
<refentry xml:id="mongodb-bson-javascript.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
2015-03-24 18:15:02 +00:00
|
|
|
<refnamediv>
|
2015-09-23 15:35:13 +00:00
|
|
|
<refname>MongoDB\BSON\Javascript::__construct</refname>
|
2015-12-17 21:57:19 +00:00
|
|
|
<refpurpose>Construct a new Javascript</refpurpose>
|
2015-03-24 18:15:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
|
|
|
<methodsynopsis>
|
2015-09-23 15:35:13 +00:00
|
|
|
<modifier>final</modifier> <modifier>public</modifier> <methodname>MongoDB\BSON\Javascript::__construct</methodname>
|
2015-12-17 21:57:19 +00:00
|
|
|
<methodparam><type>string</type><parameter>code</parameter></methodparam>
|
2020-10-30 10:45:25 +00:00
|
|
|
<methodparam choice="opt"><type class="union"><type>array</type><type>object</type></type><parameter>scope</parameter></methodparam>
|
2015-03-24 18:15:02 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2015-12-17 21:57:19 +00:00
|
|
|
<term><parameter>code</parameter> (<type>string</type>)</term>
|
2015-03-24 18:15:02 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2015-12-17 21:57:19 +00:00
|
|
|
Javascript code.
|
2015-03-24 18:15:02 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2020-10-30 10:45:25 +00:00
|
|
|
<term><parameter>scope</parameter> (<type class="union"><type>array</type><type>object</type></type>)</term>
|
2015-03-24 18:15:02 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2015-12-17 21:57:19 +00:00
|
|
|
Javascript scope.
|
2015-03-24 18:15:02 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="errors">
|
|
|
|
&reftitle.errors;
|
2015-12-17 21:57:19 +00:00
|
|
|
<simplelist>
|
|
|
|
&mongodb.throws.argumentparsing;
|
2017-01-19 23:26:03 +00:00
|
|
|
<member>Throws <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> if <parameter>code</parameter> contains null bytes.</member>
|
2015-12-17 21:57:19 +00:00
|
|
|
</simplelist>
|
2015-03-24 18:15:02 +00:00
|
|
|
</refsect1>
|
|
|
|
|
2017-01-19 23:26:03 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
2020-10-25 15:11:56 +00:00
|
|
|
<entry>PECL mongodb 1.2.0</entry>
|
2017-01-19 23:26:03 +00:00
|
|
|
<entry>
|
|
|
|
<para>
|
|
|
|
<classname>MongoDB\Driver\Exception\InvalidArgumentException</classname>
|
|
|
|
is thrown if <parameter>code</parameter> contains null bytes.
|
|
|
|
Previously, values would be truncated at the first null byte.
|
|
|
|
</para>
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2015-03-24 18:15:02 +00:00
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<example>
|
2015-09-23 15:35:13 +00:00
|
|
|
<title><function>MongoDB\BSON\Javascript::__construct</function> example</title>
|
2015-03-24 18:15:02 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2015-12-17 21:57:19 +00:00
|
|
|
$code = new MongoDB\BSON\Javascript('function() { return 1; }');
|
|
|
|
var_dump($code);
|
|
|
|
|
|
|
|
$codews = new MongoDB\BSON\Javascript('function() { return foo; }', ['foo' => 'bar']);
|
|
|
|
var_dump($codews);
|
2015-03-24 18:15:02 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
2015-12-17 21:57:19 +00:00
|
|
|
&example.outputs;
|
2015-03-24 18:15:02 +00:00
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
2015-12-17 21:57:19 +00:00
|
|
|
object(MongoDB\BSON\Javascript)#1 (2) {
|
|
|
|
["javascript"]=>
|
|
|
|
string(24) "function() { return 1; }"
|
|
|
|
["scope"]=>
|
|
|
|
object(stdClass)#2 (0) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object(MongoDB\BSON\Javascript)#2 (2) {
|
|
|
|
["javascript"]=>
|
|
|
|
string(26) "function() { return foo; }"
|
|
|
|
["scope"]=>
|
|
|
|
object(stdClass)#1 (1) {
|
|
|
|
["foo"]=>
|
|
|
|
string(3) "bar"
|
|
|
|
}
|
|
|
|
}
|
2015-03-24 18:15:02 +00:00
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<simplelist>
|
2015-12-17 21:57:19 +00:00
|
|
|
<member><link xlink:href="&url.mongodb.docs.bson;">BSON Types</link></member>
|
2015-03-24 18:15:02 +00:00
|
|
|
</simplelist>
|
|
|
|
</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
|
|
|
|
-->
|