<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.maxdb-connect">
 <refnamediv>
  <refname>maxdb_connect</refname>
  <refname>maxdb::__construct</refname>
  <refpurpose>Open a new connection to the MaxDB server</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <para>&style.procedural;</para>
  <methodsynopsis>
   <type>resource</type><methodname>maxdb_connect</methodname>
   <methodparam choice="opt"><type>string</type><parameter>host</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>passwd</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>dbname</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>0</initializer></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>socket</parameter></methodparam>
  </methodsynopsis>
  <para>&style.oop;</para>
  <constructorsynopsis>
   <methodname>maxdb::__construct</methodname>
   <methodparam choice="opt"><type>string</type><parameter>host</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>passwd</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>dbname</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>0</initializer></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>socket</parameter></methodparam>
  </constructorsynopsis>
  <para>
   The <function>maxdb_connect</function> function attempts to open a connection to the MaxDB Server
   running on <parameter>host</parameter> which can be either a host name or an IP address. Passing the
   string "localhost" to this parameter, the local host is assumed.
   If successful, the <function>maxdb_connect</function>
   will return an resource representing the connection to the database&return.falseforfailure;.
  </para>
  <para>
   The <parameter>username</parameter> and <parameter>password</parameter> parameters specify the
   username and password under which to connect to the MaxDB server. If the password is not provided
   (the &null; value is passed), the MaxDB server will attempt to authenticate the user against
   the <parameter>maxdb.default_pw</parameter> in &php.ini;.
  </para>
  <para>
   The <parameter>dbname</parameter> parameter if provided will specify the default database to be
   used when performing queries. If not provied, the entry <parameter>maxdb.default_db</parameter>
   in &php.ini; is used.
  </para>
  <para>
   The <parameter>port</parameter> and <parameter>socket</parameter> parameters are
   ignored for the MaxDB server.
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a resource which represents the connection to a MaxDB Server or
   &false; if the connection failed.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title>&style.oop;</title>
   <programlisting role="php">
<![CDATA[
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
   printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

printf("Host information: %s\n", $maxdb->host_info);

/* close connection */
$maxdb->close();
?>
]]>
  </programlisting>
  </example>
  <example>
   <title>&style.procedural;</title>
   <programlisting role="php">
<![CDATA[
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (!$link) {
   printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

printf("Host information: %s\n", maxdb_get_host_info($link));

/* close connection */
maxdb_close($link);
?>
]]>
   </programlisting>
  </example>
  &example.outputs.similar;
  <screen>
<![CDATA[
Host information: localhost
]]>
  </screen>
 </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
-->