Wamp Environment of your own configuration, extending the Oracle function library OCI

Source: Internet
Author: User
The colleague received a task yesterday to use PHP to process the contents of the Oracle database, but the PHP open Oracle extension is not as straightforward as MySQL, and requires something to open.

The first step is to download an install client package to Oracle and find your corresponding system version of Zip (note this is the system version ) under win

As of 2015-06-25, the download address is as follows http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

For example, select Instant Client for Microsoft Windows (x64) because the PHP extension is OCI, so you must select the corresponding version of the most complete, the other is not OCI, here download may need to have an account, verification can be downloaded later, Download directly with the connection is not good, if not, register it.

The second part, need to download the expansion package in the win system is the. dll file download address http://pecl.php.net/package/oci8 the next piece of crap is telling you how to find it.

Http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html Click at this address

Official Instant Client site. Pull to the end related Developer Centers inside point "php-oci8 extension"

Then tab downloads Point OCI8 to Http://pecl.php.net/package/oci8

And then how to download it doesn't say much.

Download two zip packages here, then configure PHP

Third, unzip the download of the first file, to the computer any directory, unzip to get the file directory Instantclient_12 _1 suggested that the back of the "_12_1" removed, after the revision of this will not have to move the environment variables

After entering this directory, double-click Open Adrci.exe

Get the following command-line window to prove that the client is available locally in your

Copy the directory, my F:\dev\instantclient is configured to the system's PATH environment variable,

Finally, unzip the downloaded DLL's compressed package, copy the Php_oci8.dll Php_oci8_11g.dll php_oci8_12c.dll I am currently the three, to the PHP extension package file, usually .../php/ext/directory

In fact, can not replace, but the proposal or replace the good,

Then open the php.ini to open the extension, the last one is added later, PHP was not, anyway, some DLL files in the bread are written in should not be wrong, at most when running PHP more load several libraries

Extension=php_pdo_oci.dll

Extension=php_oci8.dll; Use with Oracle 10gr2 Instant Client
Extension=php_oci8_11g.dll; Use with Oracle 11gR2 Instant Client
Extension=php_oci8_12c.dll; Use with Oracle 12c Instant Client

Then restart the httpd service, open phpinfo (); Should be able to see

Support
PDOenabled
PDO drivers MySQL, OCI, ODBC
OCI8 Support Enabled
OCI8 DTrace Support Disabled
OCI8 Version 2.0.8
Revision $Id: f04114d4d67cffea4cdc2ed3b7f0229c2caa5016 $
Oracle run-time Client Library Version 12.1.0.2.0
Oracle compile-time Instant Client Version 10.2

This means that the extension is open successfully.

Finally, the Oracle database is connected.

This gives an instance connection to the original text connection http://www.orczhou.com/index.php/2010/09/php-oci8-oracle/

1 
 Php2//configuration Information3$ora _host= "172.16.1.150";4$ora _port= "1521";5$ora _sid= "Cop";6$ora _username= "WebDev";7$ora _password= "WebDev";8$charset= "UTF8";## # ZHS16GBK # # #9Ten//Build Easy Connect string One//(if already in Tnsnames.ora, you can use connect Name directly) A$ora _connstr= "(description= (address= (PROTOCOL=TCP) -(host= ".$ora _host.") (port= ".$ora _port.")) -(C> $ora _sid.")))"; the//connecting to a database -$conn= Oci_connect ($ora _username,$ora _password,$ora _connstr); -//execute query, where $res receives a Boolean value -$stid= Oci_parse ($conn, ' select * from Dq_try_app '); +$res= Oci_execute ($stid); - +//use Oci_fetch_array to traverse the results in a while loop.  A while($row= Oci_fetch_array ($stid, oci_assoc+oci_return_nulls)) { at -foreach($row as$item) { -Echo$item." ***"; -    } -Echo"
"; - in} -//Var_dump ($stid); to?>

At this point, the entire extension plus connection is complete.

The above describes their own configuration of the WAMP environment, the expansion of the Oracle library OCI, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

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