This paper briefly analyzes the method of PHP connecting to Oracle database. Share to everyone for your reference, specific as follows:
PHP provides two sets of functions that are connected to Oracle, namely the Ora_ and OCI functions. Where the Ora_ function is slightly stale. The OCI function update is said to be better. The use of the syntax is almost the same. Your PHP installation options should be able to support both use.
Because the OCI function accesses Oracle8 above the database needs to use Oracle8 call-interface (OCI8), this extension module requires a Oracle8 client function library, so you need to connect to the remote database, you also need to install Oracle client software on the connection side , can go to http://www.oracle.com free download, this is necessary, otherwise will report the method is not defined wrong.
Steps:
1, install Apache and PHP.
2, install Oracle 10g Instant Client (or other version).
2, open the extension=php_oci8 extension in php.ini.
3, the Php/ext directory under the Php_oci8.dll file copy to the System32 directory.
4, write test script test.
<?php
$conn = oci_connect (' username ', ' password ', ' Remote Database name (EG.//192.168.1.133/ORCL) ');
if (! $conn) {
$e = Oci_error ();
Print htmlentities ($e [' message ']);
Exit;
} else {
echo "connects Oracle successfully! ";
}
? >
Errors that may occur:
1, call to undefined function oci_connect () ...: This is because the php_oci8.dll is not found, check Apache error log error.log may see: PHP startup:unable To load dynamic liberaries Php_oci8.dll ...
Workaround: Copy the Php_oci8.dll file under the Php/ext directory to the System32 directory, and if not, place the Oracle 10g Instant Client Installation directory/product/10.2.0/db_2/ The Oci.dll files in the bin directory are copied to the System32.
2, Ocienvnlscreate () failed ..... PATH includes the directory with Oracle Instant Client libraries
Workaround: reboot the machine and, if not, install Oracle 10g Instant Client.
More about PHP Interested readers can view the site topics: "PHP based on PDO Operation Database Skills Summary", "PHP+MONGODB Database Operation Skills Encyclopedia", "PHP object-oriented Programming Program Introduction", "PHP string (String) Usage Summary", " Introduction to PHP+MYSQL Database operations and a summary of PHP common database operations Tips
I hope this article will help you with the PHP program design.