PHP Connection Access Oracle is using the OCI function, the following is a collated document
1. Installing Apache and PHP Packages
Yum install-y httpd php*
2. Download Oracle Components
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
oracle-instantclient-odbc-10.2.0.4-1.i386.rpm
#rpm-IVH oracle-instantclient* (four components installed on all)
The/usr/lib/oracle/10.2.0.4/client/lib/directory is generated at this time
3. Modify the/etc/ld.so.conf file
#vim/etc/ld.so.conf
Append the following content
/usr/lib/oracle/10.2.0.4/client/lib/
#ldconfig (Execute command)
4. Download the OCI8 component
#tar ZXVF oci8-1.4.1.tgz
5. Editing the OCI8 module
#cd oci8-1.4.1
#phpize (Execute command)
#./configure--with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client/lib/
#make Install
After success the system will prompt you: Oci8.so has been successfully placed in the/usr/lib/php/modules/directory
6. Modify the php.ini file
#vim/etc/php.ini
Append the following content
Extension=oci8.so
7. Restart Apache Service
Service httpd Restart
8. Use the Phpinfo () function to view
9. Edit the PHP code connection test Oracle Database
$conn = Oci_connect (' Scott ', ' Oracle ', ' 192.168.12.133/ORCL ');
if (! $conn) {
$e = Oci_error ();
Print htmlentities ($e [' message ']);
Exit
}
$query = ' Select Ename,sal from Scott.emp ';
$stid = Oci_parse ($conn, $query);
if (! $stid) {
$e = Oci_error ($conn);
Print htmlentities ($e [' message ']);
Exit
}
$r = Oci_execute ($stid, Oci_default);
if (! $r) {
$e = Oci_error ($stid);
Echo htmlentities ($e [' message ']);
Exit
}
print '
'; while ($row = Oci_fetch_array ($stid, oci_return_nulls)) {print '
'; foreach ($row as $item) {print '
'. ($item? Htmlentities ($item): '). ' | '; } print '
'; } print '
';
Oci_close ($conn);
?>
Finally browse the page through the browser
This article from "Do not accumulate kuibu not even thousands of miles" blog, declined reprint!
http://www.bkjia.com/PHPjc/477919.html www.bkjia.com true http://www.bkjia.com/PHPjc/477919.html techarticle PHP Connection Access Oracle is using the OCI function, the following is a collated document 1. Installing Apache and PHP packages yum install-y httpd php* 2. Download Oracle Components Oracle-instantclient-basic-10.2.0.4-1.i386 ...