php-doc-en/reference/oci8/functions/oci-pconnect.xml
2013-12-04 19:49:28 +00:00

165 lines
4.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.oci-pconnect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>oci_pconnect</refname>
<refpurpose>Connect to an Oracle database using a persistent connection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>oci_pconnect</methodname>
<methodparam><type>string</type><parameter>username</parameter></methodparam>
<methodparam><type>string</type><parameter>password</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>connection_string</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>character_set</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>session_mode</parameter></methodparam>
</methodsynopsis>
<para>
Creates a persistent connection to an Oracle server and logs on.
</para>
<para>
Persistent connections are cached and re-used between requests, resulting
in reduced overhead on each page load; a typical PHP application will have
a single persistent connection open against an Oracle server per Apache
child process (or PHP FastCGI/CGI process). See the <link
linkend="features.persistent-connections">Persistent Database
Connections</link> section for more information.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>username</parameter></term>
<listitem>
<para>
The Oracle user name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>password</parameter></term>
<listitem>
<para>
The password for <parameter>username</parameter>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>connection_string</parameter></term>
<listitem>
&oci.db;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>character_set</parameter></term>
<listitem>
&oci.charset;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>session_mode</parameter></term>
<listitem>
&oci.sessionmode;
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a connection identifier or &false; on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>oci_pconnect</function> Example using Easy Connect syntax</title>
<programlisting role="php">
<![CDATA[
<?php
// Connects to the XE service (i.e. database) on the "localhost" machine
$conn = oci_pconnect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT * FROM employees');
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
See <function>oci_connect</function> for further examples of parameter usage.
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<simpara>
Starting with PHP 5.1.2 and PECL OCI8 1.1, the lifetime and
maximum number of persistent Oracle connections per PHP process can be tuned by setting
the following configuration values: <link
linkend="ini.oci8.persistent-timeout">oci8.persistent_timeout</link>,
<link linkend="ini.oci8.ping-interval">oci8.ping_interval</link> and
<link linkend="ini.oci8.max-persistent">oci8.max_persistent</link>.
</simpara>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>oci_connect</function></member>
<member><function>oci_new_connect</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:"~/.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
-->