The function ora_logon
was a function used in PHP4 , we do not use it anymore, now we use oci_login
, for example, that allows access to 12c, 11g , 10g, 9i and 8i.
Edit the file php.ini
and remove the semicolon from the following line (if it is windows)
extension=php_oci8_11g.dll
If it is * nix:
extension=oci8.so
Windows:
Download the OTN Instant Client page - probably 32bit , but if it fails and your php is 64bit, maybe you should try it.
Extract the downloaded file into C:\instantclient_11_2
Add the path to the System Variables ( PATH
)
Start Menu > Control Panel > System and Security > System > Advanced system settings (or type in the run / cmd SystemPropertiesAdvanced
)
Look for the button called Environment Variables
You have two areas, User Variables and System Variables , look in System Variables for the PATH
variable and click edit
Add this to the end (be careful not to delete what you already have) ;C:\instantclient_11_2
The function used to connect used is oci_login
, documentation function list link
p>
Example usage:
<?php
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT department_id, department_name FROM departments');
oci_execute($stid);
while (($row = oci_fetch_assoc($stid)) != false) {
echo $row['DEPARTMENT_ID'] . " " . $row['DEPARTMENT_NAME'] . "<br>\n";
}
oci_free_statement($stid);
oci_close($conn);