php-doc-en/reference/mongo/functions/mongo-connect.xml
2009-02-25 22:50:52 +00:00

119 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.2 $ -->
<refentry xml:id="function.mongo-connect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mongo_connect</refname>
<refpurpose>Connects to a database</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>mongo_connect</methodname>
<methodparam><type>string</type><parameter>host</parameter></methodparam>
<methodparam><type>bool</type><parameter>auto_reconnect</parameter></methodparam>
</methodsynopsis>
<para>
Creates a new database connection object.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>host</parameter>
</term>
<listitem>
<para>
Address of the database to which to connect.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>auto_reconnect</parameter>
</term>
<listitem>
<para>
If the driver should attempt to reconnect if
the database connection is lost.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
<para>
If able to connect, the connection resource is returned.
Otherwise, false.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
If the server name is invalid (null or the empty string).
If the driver is unable to connect to the host.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mongo_connect</function> example</title>
<para>
To connect to a Mongo database running locally on the default port:
</para>
<programlisting role="php">
<![CDATA[
<?php
$connection = mongo_connect("localhost", true);
// or, equivalently
$connection = mongo_connect("localhost:27017", true);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mongo_close</function></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
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../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
-->