tnsnames.ora
configuration excerpt:
1
2
3
4
5
|
MYSERVICE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = database_hostname_or_ip.com)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME=myservice)))
|
Connect and execute a prepared statement from PHP code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<?php
$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
|