Console App: Could not find DB driver

Hello everyone!

Need a help for understand what is wrong and fix it!

Yii version : 1.0.7

I try create a console application by instruction, all work done with simple actions.

When i try begin use DB i catch error:

2009/08/04 09:04:18 [error] [exception.CDbException] exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in C:\WAPP\apache2\htdocs\yii\framework\db\CDbConnection.php:248

Stack trace:

#0 C:\WAPP\apache2\htdocs\yii\framework\db\CDbConnection.php(223): CDbConnection->open()

#1 C:\WAPP\apache2\htdocs\yii\framework\db\CDbConnection.php(202): CDbConnection->setActive(true)

#2 C:\WAPP\apache2\htdocs\yii\framework\base\CModule.php(353): CDbConnection->init()

#3 C:\WAPP\apache2\htdocs\yii\framework\base\CModule.php(91): CModule->getComponent('db')

#4 C:\WAPP\apache2\htdocs\seoportal\protected\commands\EmailCommand.php(7): CModule->__get('db')

#5 C:\WAPP\apache2\htdocs\yii\framework\console\CConsoleCommandRunner.php(62): EmailCommand->run(Array)

#6 C:\WAPP\apache2\htdocs\yii\framework\console\CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#7 C:\WAPP\apache2\htdocs\yii\framework\base\CApplication.php(133): CConsoleApplication->processRequest()

#8 C:\WAPP\apache2\htdocs\seoportal\cli.php(10): CApplication->run()

#9 {main}

my cli.php:


// change the following paths if necessary




// remove the following line when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);



my protected/config/console.php have components => db same with main php for web part(work fine with db)

piece of db :


            'connectionString'=>'pgsql:host= port=5432 dbname=eler0623',




my EmailCommand.php:

class EmailCommand extends CConsoleCommand


    public function run($args)


//      CVarDumper::dump(SearchRequest::model()->getDbConnection());




        echo 'DONE!'."\n";



My command, executed from application base dir: php cli.php email

For prevent question about pdo look phpinfo():

PDO support	enabled

PDO drivers 	mysql, pgsql


PDO Driver for MySQL, client library version	5.0.45


PDO Driver for PostgreSQL	enabled

PostgreSQL(libpq) Version 	8.3.1

Module version 	1.0.2

Revision 	$Id: pdo_pgsql.c,v 2007/12/31 07:20:10 sebastian Exp $ 

And Yes under console mode i see only pdo_mysql driver i check it:

       foreach(PDO::getAvailableDrivers() as $driver)


            echo $driver."\n";


On the test server (pre production) pgpdo is presented in console mode but i catch error from system: segmentation fault on the end of script.

I guess the console application does not use the same php ini as the webserver. Provide the proper ini file with the -c option

php -c path/to/ini <script file>

I think same as you but trying with php -c path/to/ini <script file> did not get luck.

And i have not any other php.ini files in my test system.

Oh I missed something obvious :)


            'connectionString'=>'pgsql:host= port=5432 dbname=eler0623',




Your connection string is wrong. your forget ‘;’ between host, port and db name.






something else that was the case on my system, I had multiple versions of PHP installed, the web server was correctly configured to load the right files, but the PHP CLI was using the old one, which did not recognize the DB drivers.

Using an absolute path to the php binary solved it.