PHP Connect Oracle Database _php Tutorial

Source: Internet
Author: User
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 ' '; } print ' '; } print '
'. ($item? Htmlentities ($item): '). '
';

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.