mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-21 03:18:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@301207 c90b9560-bf6c-de11-be94-00142212c4b1
128 lines
3.1 KiB
XML
128 lines
3.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="mongodbref.create" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>MongoDBRef::create</refname>
|
|
<refpurpose>Creates a new database reference</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <modifier>static</modifier> <type>array</type><methodname>MongoDBRef::create</methodname>
|
|
<methodparam><type>string</type><parameter>collection</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>id</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>database</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
If no database is given, the current database is used.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>collection</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Collection name (without the database name).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>id</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The _id field of the object to which to link.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>database</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Database name.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns the reference.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><function>MongoDBRef::create</function> example</title>
|
|
<para>
|
|
This creates a database reference to a document in the
|
|
<literal>addresses</literal> collection. The
|
|
<function>MongoCollection::getName</function> function returns the name of
|
|
the collection (not including the database name).
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$addresses = $db->addresses;
|
|
$people = $db->people;
|
|
|
|
// save $address so it has an _id
|
|
$addresses->insert($address);
|
|
|
|
// create a reference
|
|
$ref = MongoDBRef::create($addresses->getName(), $address['_id']);
|
|
|
|
// set the field in $person
|
|
$person['address'] = $ref;
|
|
$people->save($person);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>MongoDB::createDBRef</methodname></member>
|
|
<member><methodname>MongoCollection::createDBRef</methodname></member>
|
|
</simplelist>
|
|
</para>
|
|
</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
|
|
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
|
|
-->
|