php-doc-en/reference/maxdb/functions/maxdb-connect.xml
Thomas Simenec ad2d322256 Update documentation
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@181642 c90b9560-bf6c-de11-be94-00142212c4b1
2005-03-08 16:39:06 +00:00

138 lines
4.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<refentry id="function.maxdb-connect">
<refnamediv>
<refname>maxdb_connect</refname>
<refname>maxdb()</refname>
<refpurpose>Open a new connection to the MaxDB server</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>Procedural style</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></methodparam>
<methodparam choice='opt'><type>string</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (constructor):</para>
<classsynopsis>
<ooclass><classname>maxdb</classname></ooclass>
<constructorsynopsis>
<methodname>__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></methodparam>
<methodparam choice='opt'><type>string</type><parameter>socket</parameter></methodparam>
</constructorsynopsis>
</classsynopsis>
<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, or &false; on failure.
</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>
<title>Return values</title>
<para>
Returns a resource which represents the connection to a MaxDB Server or
&false; if the connection failed.
</para>
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Object oriented style</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>Procedural style</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>
<para>
The above examples would produce the following output:
</para>
<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:"../../../../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
-->