php-doc-en/reference/maxdb/functions/maxdb-real-connect.xml

172 lines
4.9 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.maxdb-real-connect">
<refnamediv>
<refname>maxdb_real_connect</refname>
<refname>maxdb->real_connect</refname>
<refpurpose>Opens a connection to a MaxDB server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>Procedural style</para>
<methodsynopsis>
<type>bool</type><methodname>maxdb_real_connect</methodname>
<methodparam><type>resource</type><parameter>link</parameter></methodparam>
<methodparam choice='opt'><type>string</type><parameter>hostname</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 (method)</para>
<classsynopsis>
<ooclass><classname>maxdb</classname></ooclass>
<methodsynopsis>
<type>bool</type>
<methodname>real_connect</methodname>
<methodparam choice='opt'><type>string</type><parameter>hostname</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>
</classsynopsis>
<para>
<function>maxdb_real_connect</function> attempts to establish a
connection to a MaxDB database engine running on
<parameter>hostname</parameter>.
</para>
<para>
This function differs from <function>maxdb_connect</function>:
</para>
<itemizedlist>
<listitem>
<para>
<function>maxdb_real_connect</function> needs a valid resource which has
to be created by function <function>maxdb_init</function>
</para>
</listitem>
<listitem>
<para>
With function <function>maxdb_options</function> you can set various options for connection.
</para>
</listitem>
</itemizedlist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
/* create a connection object which is not connected */
$maxdb = maxdb_init();
/* set connection options */
$maxdb->options(MAXDB_UNICODE, "FALSE");
$maxdb->options(MAXDB_TIMEOUT, 5);
/* connect to server */
$maxdb->real_connect('localhost', 'MONA', 'RED', 'DEMODB');
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
printf ("Connection: %s\n.", $maxdb->host_info);
$maxdb->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
/* create a connection object which is not connected */
$link = maxdb_init();
/* set connection options */
maxdb_options($link, MAXDB_UNICODE, "FALSE");
maxdb_options($link, MAXDB_TIMEOUT, 5);
/* connect to server */
maxdb_real_connect($link, 'localhost', 'MONA', 'RED', 'DEMODB');
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
printf ("Connection: %s\n.", maxdb_get_host_info($link));
maxdb_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Connection: localhost <...>
]]>
</screen>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>maxdb_connect</function></member>
<member><function>maxdb_init</function></member>
<member><function>maxdb_options</function></member>
<member><function>maxdb_ssl_set</function></member>
<member><function>maxdb_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
-->