Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.

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



854
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.phalconphp.com/en/latest/api/Phalcon%5Db%5Adapter%5Pdo%5Oracle.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 <?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.



854
Accepted
answer

Finally found an answer on stack: http://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/instantclient121,12.1 to the ./configure command other wise, worked great and i'm up and running!