Working code-
$dbh = new PDO('oci:dbname=localhost/XE', 'hr', 'hr');
$s = $dbh->prepare("select * from Employees");
$s->execute();
while (($r = $s->fetch(PDO::FETCH_ASSOC)) != false) {
echo htmlentities($r['FIRST_NAME']) . " " . $r['LAST_NAME'] . "<br>";
}
Not working code (Error-Call to undefined function oci_connect(), oci_new_connect())
/*Using oci_connect */
$conn=oci_connect("hr","hr","localhost/XE");
If (!$conn)
echo 'Failed to connect to Oracle';
else
echo 'Succesfully connected with Oracle DB';
oci_close($conn);
/*Using oci_new_connect*/
$c = oci_new_connect('hr', 'hr', 'localhost/XE');
$s = oci_parse($c, 'select city from locations');
oci_execute($s);
while (($res = oci_fetch_array($s, OCI_ASSOC)) != false) {
echo htmlentities($res['CITY']) . "<br>";
}
phpinfo are as phpinfo details I have placed instantclient for 11g in c and set PATH variable also
Tried every instantclient extensions one by one-
- extension=php_oci8.dll,
- extension=php_oci8_11g.dll,
- extension=php_oci8_12c.dll
I am using Oracle 11g