Extending the Oracle Function library (OCI) in the WAMP environment, wampoci_php tutorial

Source: Internet
Author: User

Extended Oracle Function Library (OCI) in Wamp environment, WAMPOCI

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.dllextension=php_oci8.dll   ; Use with Oracle 10gr2 Instant Clientextension=php_oci8_11g.dll; Use with Oracle 11gR2 Instant Clientextension=php_oci8_12c.dll; Use with Oracle 12c  Instant Client

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

PDO support enabledpdo drivers MySQL, OCI, ODBC OCI8 support enabledOCI8 DTrace support DisabledOCI8 Version 2.0.8Revision $Id: f04114d4d67cffea4cdc2ed3b7f0229c2caa5016 $Oracle run-time Client Library Version 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/

<?php//configuration information $ora_host = "", $ora _port= "1521", $ora _sid = "Cop", $ora _username = "WebDev"; $ora _password = " WebDev "; $charset =" UTF8 "; # # # ZHS16GBK ###//build Easy Connect string//(if you already have it in Tnsnames.ora, you can use connect Name directly) $ora _connstr = "(Description= ( Address= (PROTOCOL=TCP) (host= ". $ora _host.") (port= ". $ora _port.")) (Connect_data= (service_name= ". $ora _sid."))) "; /Connection 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 result in the while loop. while ($row = Oci_fetch_array ($stid, Oci_assoc+oci_return_nulls)) {    foreach ($row as $item) {    echo $item. " ***";  }  echo "
"; } Var_dump ($stid); ? >

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

The above mentioned is the whole content of this article, I hope you can like.

http://www.bkjia.com/PHPjc/1022782.html www.bkjia.com true http://www.bkjia.com/PHPjc/1022782.html techarticle Extending the Oracle function library (OCI) in the WAMP environment, the WAMPOCI colleague received a task yesterday to process the contents of the Oracle database in PHP, but the PHP open Oracle extension is not as straightforward as MySQL.

  • Related Article

    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.