php-doc-en/reference/oci8/reference.xml
Mehdi Achour 0ac403fe47 new docs, written by Antony Dovgal
# need an english reviewer


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@153134 c90b9560-bf6c-de11-be94-00142212c4b1
2004-03-08 14:12:17 +00:00

222 lines
5.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<reference id="ref.oci8">
<title>Oracle 8 functions</title>
<titleabbrev>OCI8</titleabbrev>
<partintro>
<section id="oci8.intro">
&reftitle.intro;
<para>
These functions allow you to access Oracle9, Oracle8 and Oracle7 databases.
It uses the Oracle Call Interface (OCI).
</para>
<para>
This extension is more flexible than the
<link linkend="ref.oracle">old Oracle</link>
extension. It supports binding of global and local PHP variables
to Oracle placeholders, has full LOB, FILE and ROWID support
and allows you to use user-supplied define variables.
You are recommended to use this extension instead of
<link linkend="ref.oracle">old Oracle</link> extension where
possible.
</para>
</section>
<section id="oci8.requirements">
&reftitle.required;
<para>
You will need the Oracle client libraries to use this extension.
Windows users will need at least Oracle version 8.1 to use the
<filename>php_oci8.dll</filename> dll.
</para>
<para>
Before using this extension, make sure that you have set up your
Oracle environment variables properly for the Oracle user, as well
as your web daemon user. The variables you might need to set are as
follows:
<itemizedlist>
<listitem>
<simpara>
ORACLE_HOME
</simpara>
</listitem>
<listitem>
<simpara>
ORACLE_SID
</simpara>
</listitem>
<listitem>
<simpara>
LD_PRELOAD
</simpara>
</listitem>
<listitem>
<simpara>
LD_LIBRARY_PATH
</simpara>
</listitem>
<listitem>
<simpara>
NLS_LANG
</simpara>
</listitem>
<listitem>
<simpara>
ORA_NLS33
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
After setting up the environment variables for your webserver user,
be sure to also add the webserver user (nobody, www) to the oracle
group.
</para>
<note>
<title>If your webserver doesn't start or crashes at startup</title>
<para>
Check that Apache is linked with the pthread library:
</para>
<para>
<informalexample>
<screen>
<![CDATA[
# ldd /www/apache/bin/httpd
libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000)
libm.so.6 => /lib/libm.so.6 (0x4002f000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x4004c000)
libdl.so.2 => /lib/libdl.so.2 (0x4007a000)
libc.so.6 => /lib/libc.so.6 (0x4007e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
]]>
</screen>
</informalexample>
</para>
<para>
If the libpthread is not listed you have to reinstall Apache:
</para>
<para>
<informalexample>
<screen>
<![CDATA[
# cd /usr/src/apache_1.3.xx
# make clean
# LIBS=-lpthread ./config.status
# make
# make install
]]>
</screen>
</informalexample>
</para>
<para>
Please note that on some systems like UnixWare it is libthread
instead of libpthread. PHP and Apache have to be configured
with EXTRA_LIBS=-lthread.
</para>
</note>
</section>
&reference.oci8.configure;
<section id="oci8.configuration">
&reftitle.runtime;
&no.config;
</section>
<section id="oci8.resources">
&reftitle.resources;
<para>
</para>
</section>
&reference.oci8.constants;
<section id="oci8.examples">
&reftitle.examples;
<para>
<example>
<title>OCI Hints</title>
<programlisting role="php">
<![CDATA[
<?php
// by sergo at bacup dot ru
// Use option: OCI_DEFAULT for execute command to delay execution
OCIExecute($stmt, OCI_DEFAULT);
// for retrieve data use (after fetch):
$result = OCIResult($stmt, $n);
if (is_object($result)) $result = $result->load();
// For INSERT or UPDATE statement use:
$sql = "insert into table (field1, field2) values (field1 = 'value',
field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save("some text");
OCICommit($conn);
?>
]]>
</programlisting>
</example>
</para>
<para>
You can easily access stored procedures in the same way as you
would from the commands line.
<example>
<title>Using Stored Procedures</title>
<programlisting role="php">
<![CDATA[
<?php
// by webmaster at remoterealty dot com
$sth = OCIParse($dbh, "begin sp_newaddress( :address_id, '$firstname',
'$lastname', '$company', '$address1', '$address2', '$city', '$state',
'$postalcode', '$country', :error_code );end;");
// This calls stored procedure sp_newaddress, with :address_id being an
// in/out variable and :error_code being an out variable.
// Then you do the binding:
OCIBindByName($sth, ":address_id", $addr_id, 10);
OCIBindByName($sth, ":error_code", $errorcode, 10);
OCIExecute($sth);
?>
]]>
</programlisting>
</example>
</para>
</section>
</partintro>
&reference.oci8.functions;
</reference>
<!-- 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
-->