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.

ORM object has not access to database

Hi everybody,

please help me to resolve some problem related to my project.

I have created model class Users extends from \Phalcon\Mvc\Model. After i make a simple select query and get the follow error "SQLSTATE[28000] [1045] Access denied for user 'postgres'@'localhost' (using password: YES)" the sample code: $users = new Users(); $result = $users::query()->execute()->toArray();

But when i create connect to database via php core function pgconnect, all works right the sample code: pgconnect("host=localhost dbname=adminpaybox user=postgres password=admin"); $query = <<<SQL select * from users; SQL; $result = pgquery($query);



1.9k

Can you cut/paste your "db" service



385

return new \Phalcon\Config(array( 'database' => array( 'adapter' => 'Postgresql', 'host' => 'localhost', 'username' => 'postgres', 'password' => 'admin', 'dbname' => 'admin_paybox', 'schema' => 'public' ) )

$di = new FactoryDefault();

$di->set('db', function () use ($config) { return new DbAdapter(array( 'host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname )); });

Can you cut/paste your "db" service



385
Accepted
answer

I have found the resolving the problem. For Postgresql need to use \Phalcon\Db\Adapter\Pdo\Postgresql, instead DbAdapter in service. DbAdapter is used only for Mysql