1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
<?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
-->
|