Connect to an Oracle database using php
-
I need to connect to an Oracle database server with system identifier PROD, using the login "scott" and password "tiger." Can anyone help
-
Answer:
You could use http://php.net/manual/en/book.pdo.php to connect to oracle. That way you can also easily change between different types of databases without changes to your code, making it very portable. But note that the Oracle driver for PDO is marked as experimental so it might be changed with later releases of PHP. Note* Never tested PDO for oracle myself, but it's brilliant for other types of databases and makes you able to switch between different databases easily.
Poonam Bhatt at Stack Overflow Visit the source
Other answers
this is sample extract from http://www.orafaq.com/wiki/Tnsnames.ora: MYSERVICE = (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)(HOST = database_hostname_or_ip.com)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME=myservice))) This is sample script to connect and execute query: $oracledb["host"] = "MYSERVICE"; # service name in the tnsnames.ora file $oracledb["user"] = "myuser"; # username $oracledb["pass"] = "mypass"; # password $oracledb["library"] = "OCI"; $connect_id = ocilogon($oracledb["user"], $oracledb["pass"], $oracledb["host"]); $query = "SELECT * FROM table"; $statement = ociparse($connect_id, $query); ociexecute($statement); $result = array(); while(ocifetchinto($statement, $tmp, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) { array_push($result, $tmp); } ocifreestatement($statement); var_dump($result); # result is here
Lyuben
Use PHP function http://php.net/manual/en/function.oci-connect.php to connecto to oracle db
Shameer
Related Q & A:
- How To Build Business Directory Using Php Mysql?Best solution by Stack Overflow
- How to parse .log file and insert into database in PHP?Best solution by unix.com
- How to know the Oracle Database Name?Best solution by Stack Overflow
- How to read csv file using php?Best solution by Stack Overflow
- How to connect to a Pervasive Database using javascript?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.