matt
matt

Reputation: 2352

ZF2 PDO error when loading Action from console

I have an application that works correctly when accessed from a browser, I can query PostgreSQL without any problems but when I try to load it via the console I get the error:

Zend\Db\Adapter\Exception\RuntimeException
Connect Error: could not find driver

The routing, controller and action load correctly as long as I don't try to query the database.

Is there anything I'm missing, maybe something else I need to set when trying to query the DB from the console?

From the console I run it via php /web/public/index.php action which works until I add the DB calls.

//UPDATE

My global.php looks like:

'db' => array(
     'driver'         => 'Pdo',
     'dsn'            => 'pgsql:dbname=myDB;host=localhost',
     'driver_options' => array(
         PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
     ),
 ),
 'service_manager' => array(
     'factories' => array(
         'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
     ),
 ),

Upvotes: 0

Views: 84

Answers (1)

PAlphen
PAlphen

Reputation: 186

for brevity;

After discussion on chat, turns out server was configured to handle http and console requests over different PHP binary's. Changing the php path solved the problem.

Upvotes: 1

Related Questions