Do not connect oracle database with PHP through PDO
As documented on the PHP manual page, and mentioned in a comment by mario, a PDO DSN for OCI uses dbname
, not schema
or host
, in its definition:
$conn = new PDO('oci:dbname=localhost/XE', $user, $pass);
The localhost/XE
format you are using is an 'EZCONNECT' string. The first part defines the host (localhost) and the second part the service (XE).
You could also use a 'regular' connection string (as normally defined in a tnsnames.ora
file) instead:
$conn_string = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)))';
$conn = new PDO('oci:dbname=' . $conn_string, $user, $pass);