Extended oracle function library (oci) in WAMP environment)

Source: Internet
Author: User
This article introduces the process of extending the Oracle function library for php in windows. it is very detailed. if you need it, you can refer to it. My colleague received a task yesterday to use php to process the content of the oracle Database. However, it is not as easy to use php to open the oracle extension as mysql does. I need something else to open it.

The first step is to download an install client package from the oracle official website and find the zip file of your corresponding system version under win (note that this is the system version)

As of, the following http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

For example, if you select Instant Client for Microsoft Windows (x64), because php expands to OCI, you must select the most comprehensive version. there is no OCI for others. you may need an account to download the file here, after verification, you can download it. it is not useful to directly use a connection for download. if not, just register it.

The second part, you need to download the extension package in the Windows system, that is, the. dll file http://pecl.php.net/package/oci8 below a piece of nonsense is to tell you how to find

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

Official Instant Client site. click "PHP-OCI8 extension" in the last Related Developer Centers"

Then tab downloads point OCI8 to http://pecl.php.net/package/oci8

Then I won't say much about how to download it.

Download two zip packages and configure PHP

Third, extract the first downloaded file to any directory on the computer. decompress the package to obtain the file directory instantclient_12 _ 1. we recommend that you remove "_ 12_1" from it. in the future, you will not need to change the environment variable.

Double-click the directory to open adrci.exe.

Obtain the following command line window to prove that the client is available locally.

Copy directory, which is the path environment variable configured to the system by F: \ dev \ instantclient,

4. decompress the downloaded dll package and copy php_oci8.dll php_oci8_11g.dll php_oci8_12c.dll. I am currently using these three packages. the extension package files to php are usually ...... /php/ext/Directory

It can be replaced, but it is recommended to replace it,

Then open php. ini opened the extension, and the last one was added later. php didn't have it. it should be wrong to write all the dll files in the above package. at most, several more libraries will be loaded when php is run.

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 and open phpinfo (); you 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 indicates that the extension is successfully opened.

The last step is to connect to the oracle database.

Connect an instance to the original 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 ####// construct Easy Connect string // (if tnsnames. ora already exists. you can directly use Connect Name) $ ora_connstr = "(description = (address = (protocol = tcp) (host = ". $ ora_host. ") (port = ". $ ora_port. ") (connect_data = (service_name = ". $ ora_sid. ")"; // connect to the database $ conn = oci_connect ($ ora_username, $ Ora_password, $ ora_connstr); // execute the Query. Here $ res receives a boolean value $ stid = oci_parse ($ conn, 'select * FROM dq_try_app '); $ res = oci_execute ($ stid); // use oci_fetch_array in the while loop to traverse the result. While ($ row = oci_fetch_array ($ stid, OCI_ASSOC + OCI_RETURN_NULLS) {foreach ($ row as $ item) {echo $ item. "***";} echo"
";}// Var_dump ($ stid) ;?>

Now, the entire extension and connection are complete.

The above is all the content of this article. I hope you will like it.

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.