How to connect php to oracle database and simple analysis

墨辰丷
Release: 2023-03-29 12:18:02
Original
3988 people have browsed it

This article mainly introduces the method of connecting PHP to the Oracle database, briefly analyzes the common methods and specific operating techniques of PHP connecting to the Oracle database, and summarizes and analyzes possible problems. Friends in need can refer to it

This article briefly analyzes the method of connecting PHP to the Oracle database. Share it with everyone for your reference, the details are as follows:

PHP provides two sets of functions to connect to Oracle, namely ORA_ and OCI functions. The ORA_ function is slightly outdated. The OCI function update is said to be better. The usage syntax of the two is almost the same. Your PHP installation options should support the use of both.

Since OCI functions need to use Oracle8 Call-Interface (OCI8) to access databases above oracle8, this extension module requires the client function library of oracle8, so if you need to connect to a remote database, you also need a connection end To install the Oracle client software, you can download it for free from http://www.oracle.com. This is necessary, otherwise an undefined method error will be reported.

Steps:

1. Install apache and php.
2. Install Oracle 10g Instant Client (or other versions).
2. Open the extension=php_oci8 extension in php.ini.
3. Copy the php_oci8.dll file in the php/ext directory to the system32 directory.
4. Write test scripts for testing.

Copy after login

Possible errors:

1. call to undefined function oci_connect()...: This is because php_oci8.dll was not found, check You may see the error log error.log of apache: php startup:unable to load dynamic liberaries php_oci8.dll......

Solution:Change the php/ext directory Copy the php_oci8.dll file to the system32 directory. If it still doesn't work, copy the oci.dll file in the /product/10.2.0/db_2/BIN directory under the Oracle 10g Instant Client installation directory to the system32 directory.

2. OCIEnvNlsCreate() failed.... PATH includes the directory with Oracle Instant Client libraries

Solution:Restart the machine, if it still doesn't work, Install Oracle 10g Instant Client.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

phpDetailed explanation of WeChat development access example

PHP MySQL implements fuzzy query of employee information Function

Summary of three commonly used design patterns in PHP

The above is the detailed content of How to connect php to oracle database and simple analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!