We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

Oracle Database Connection error

I have been trying to connect to Oracle Database using the following code:

$di = new \Phalcon\DI\FactoryDefault();

// Set up the database service
$di->set('db', function(){
    return new \Phalcon\Db\Adapter\Pdo\Oracle(array(
        "dbname" => "localhost/xe",
        "username" => "username",
        "password" => "password",

// Bind the DI to the application

However, I continue to get the following error:

phql Table "robots" doesn't exist on database when dumping meta-data for Robots

Any idea where I might be going wrong? Any help is appreciated. Thanks a lot.

edited Nov '16

You wrote a wrong dbname/host.

Must be separately host and dbname. see doc: http://docs.phalcon.io/en/latest/reference/tutorial.html#setting-a-database-connection

 //Set the database service
$di->set('db', function(){
        return new \Phalcon\Db\Adapter\Pdo\Oracle(array(
            "host" => "localhost",
            "username" => "username",
            "password" => "password",
            "dbname" => "xe"


Your connection to oracle is correct.

PDO_Oracle dont need host parameter.

I generally use in connection tns_name, check this

$connection = new \Phalcon\Db\Adapter\Pdo\Oracle(array(
    'username' => 'PHALCON',
    'password' => 'Phalcon',
    'charset' => 'AL32UTF8',

Oracle need the schema parameter in their models to function properly.

you can set on your models as follows:

class Robots extends \Phalcon\Mvc\Model {

    public function initialize() {


Another point of attention, are the names of objects which are usually configured by default in uppercase.

Sry for my bad Brazinglish :)


@Marcio :Thanks a lot for your response. I realised I was getting an error because my tables and schema were in uppercase whereas I had used lower case for the tables in my code. Now I am able to connect to Oracle Database. Thanks a lot for your help. :)

Did you have to install pdo_oci to get it working? It is experimental according to the PHP manual. Has anyone used oci8 library with phalcon?