How to connect an Oracle database from PHP

匿名 (未验证) 提交于 2019-12-03 01:29:01

问题:

How do I connect to an Oracle database from PHP?

回答1:

Forth link in google after searching for your exact questions brought up the following link: http://me2learn.wordpress.com/2008/10/18/connect-php-with-oracle-database/



回答2:

I assumed you want to connect php with oracle databases. so, I give you two of file, this is represent a basic php-oracle for your reference. good luck!

form.php

login.php



回答3:

PHP provides Oracle OCI8 functions. Other options are PDO with the Oracle Driver and (if oracle supports it) ODBC.



回答4:

I have created a connection in easiest way as follows:

Step 1. Determine what PHP bit version (32-bit or 64-bit) you are running. If PHP_INT_SIZE is value of 4, then version is 32-bit. If PHP_INT_SIZE is value of 8, then version is 64-bit. Use the following code below:

Step 2. Download the "InstantClient Package - Basic" for Windows from the [OTN InstantClient page][1]. Make sure you download the corresponding bit-version from step 1.

Step 3. Unzip the InstantClient files to C:\instantclient_11_2 and edit the Windows PATH environment to include C:\instantclient_11_2. For example, on Windows XP, follow `Start > Control Panel > System >

Advanced > Environment Variables` and edit `PATH` in the `System` > variables list. 
Step 3. In your `php.ini` file, enable the following lines: 
extension=php_oci8_11g.dll extension=php_openssl.dll  Finally, restart your Apache server.  http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html 


回答5:

Its unclear from your question if you want to configure your PHP install to connect to oracle or if you just want the php syntax to make the connection?

As there is already a Windows specific answer and the connection systax here, these links should point you in the right direction for a linux based install of the Oracle client libraries.

The basic steps are..

  • uncompress the Oracle Client Libraries (Basic, SDK and sqlplus packages)
  • add LD_LIBRARY_PATH to your environment
  • fix some symlinks for the libraries
  • install PECL OCI8, this compiles the shared object so your system will need a C compiler
  • enable the extension in the php.ini file. Remember your system might have separate php.ini files for CLI and webserver so check for both.
  • restart your webserver

These steps are on multiple blog posts so I won't reinvent the wheel here. but here are some links that look pretty good



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!