We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon cannot find oracle driver

I am attempting to connect to an oracle database, however, i keep getting: "PHP message: PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

I can connect to the oracle database via vanilla PHP just fine (using oci pconnect) but gonig through Phalcon, no such luck.

My connection is:

<?php
    $connection = new \Phalcon\Db\Adapter\Pdo\Oracle(array(
        'dbname' => "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = external-host.com)(PORT = 1521))) (CONNECT_DATA=(SID=A.B)))",
        'username' => 'USERNAME',
        'password' => 'PASSWORD',
        'charset' => 'AL32UTF8',
        'options' => [PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_PERSISTENT => TRUE,],
    ));

This is oracle 12.1 on Ubuntu 14. I have the oracle client installed, I can connect to the database via vanilla PHP and via command line, just not through phalcon. Any help is greatly appreciated!!

As the error message states, PHP PDO cannot recognize your connection string, it's not an issue with Phalcon.

https://php.net/manual/en/ref.pdo-oci.connection.php



3.0k
edited Nov '15

What should my connection string look like then? The one posted above has documented success, and matching the Phalcon docs: https://docs.phalcon.io/en/latest/api/Phalcon_Db_Adapter_Pdo_Oracle.html

<?php
$arrOr = array(
        "dbname" => "//host:1521/SID",
        "username" => "user",
        "password" => "pass"
       );

    $connection = new \Phalcon\Db\Adapter\Pdo\Oracle($arrOr);

That still throws a cannot find driver error: 'PDOException' with message 'could not find driver'

When I use vanilla PHP:

<?php
$conn = oci_pconnect("user", "pass", "//host:1521/sid" );

All works fine. So I'm still throughly confused as to what I'm doing wrong moving it into the Phalcon framework.



3.0k
Accepted
answer

Finally found an answer on stack: https://stackoverflow.com/questions/21936091/how-to-install-oracle-instantclient-and-pdo-oci-on-ubuntu-machine Scroll down to the response that deals with pulling down the source of your version of PHP. I followed those steps, with 2 exceptions:

  1. 12.1 is a listed version in my PHP, so no need to add it to the config.m3
  2. I had to add --with-pdo-oci=instantclient,/path/to/instantclient_12_1,12.1 to the ./configure command other wise, worked great and i'm up and running!