Using yiic model X, Fails to connect to MySQL

Hi,

running the yiic tool for creating CRUD operations fails to connect to my database. When issue>> model User,

the error message is: 'DbConnection failed to open the DB connection: could not find driver'

I have a working MAMP installation with PDO enabled (when checking PHP info). The only change I've made to the application after running "yiic webapp" is in the config.php and the db section:

'db'=>array(


		'class' => 'CDbConnection',


		'connectionString'=>'mysql:host=127.0.0.1;dbname=blog',


		'username'=>'root',

            'password'=>'root',

	),

Please help. Thanks

It's because your CLI PHP is using a different php.ini that does not enable the needed PDO driver. You may use the following command to start yiic shell instead to ensure it uses the right php.ini:

php -c path/to/php.ini protected/yiic shell

Thank's!

This command did it for me

php -c /Applications/MAMP/conf/PHP5/php.ini yiic.php shell …/…/www/blog/index.php

P.S. It took me a while (new to mac) figure out that "Program" library showed in Finder actually is named "Applications"

Read all about it here:

http://www.yiiframew…totype.scaffold

I have similar problem with SQLite. I try to generate user’s model. I don’t understand this command. I use server2go portable server.

C:\server2go\htdocs\blog\index.php - my blog aplication index

C:\server2go\server\config_tpl\php.ini - my php.ini file

How should I write the shell command to work ?

Thx in advance

I have PDO enabled.

Edit yiic.bat with Qiang modification:

C:\>php -c ../config_tpl/php.ini protected/yiic shell

Could not open input file: protected/yiic

I’ve checked localization of php.ini file with phpinfo(), and it is set to C:\Documents and Settings\Ricardo\Local Settings\Temp\Server2Go_3776\php.ini

Now I have command:

C:\server2go\htdocs\blog>php -c "C:\Documents and Settings\Ricardo\Local Settings\Temp\Server2Go_3776\php.ini" protected\yiic.php shell index.php

and it works, but maybe someone will know how to change it to another php.ini ?

C:\server2go\htdocs\blog\index.php - my blog aplication index

C:\server2go\server\config_tpl\php.ini - my php.ini file