How to connect from php to Oracle DB 12c?

2019-08-24 17:17发布

问题:

I am using XAMPP v3.2.2 and I am trying to connect from PHP to Oracle database 12c.

I have already commented out the extension php_oci8_12c.dll in php.ini, restarted Apache, and installed Oracle instantclient_12_2 32bit.

However, I am getting this error:

Fatal error: Uncaught Error: Call to undefined function oci_connect()

回答1:

Follow instructions for XAMPP v3.2.2 and Oracle database 12c config.

  1. Download instantclient_12_2 and unzip to c:\instantclient_12_2 (make sure your xamp and instantclient both are same architechture x86 or 64-bit)
  2. setup ENVIRONMENT PATH for c:\instantclient_12_2 before any oracle directory. Restart PC
  3. download oci8 dll from http://pecl.php.net/package/oci8/2.0.6/windows
  4. select 5.5 Thread Safe (TS) x64 from above link
  5. unzip and copy all files to c:/xampp/php/ext directory
  6. open php.ini remove (;) for extension=php_oci8.dll, extension=php_oci8_12c.dll and save it
  7. restart apache
  8. look phpinfo and search for oci8 module if found and enabled then ok.
  9. test with php oracle connection script .