MAMP/LAMP STACK + database connectivity

I kept getting errors when trying to use the "model User" command from the shell.

example1: Warning: you do not have a 'db' database connection as required by Active Record

example2: exception 'CDbException' with message 'Active Record requires a "db" CDbConnecti

on application component.' in (path to webroot)/yii/framework/db/ar/CActiveRecord.


Stack trace: (followed by a laundry list of errors)

I've tried to figure out how to make the shell command "model User" work, but had no luck untill I looked at which version of php it's using.

$>which php


…in this case, it was the wrong one since I was using a lamp stack that I got from

so I had to invoke the shell command (i.e. "model User") using the version of php that came with the stack instead of using the OS version of php (running stacks on both mac OS X and Ubuntu 8.04). I also had to include the mysql socket that was on the stack so it won't go to the OS version as well.

here's my array that's in the protected/config/main.php file







then I invoke the command using:

htdocs/testdrive$> /home/michael/lamp/php/bin/php  …/yii/framework/yiic shell

and this so far has worked for me

I also have a problem  when trying to use the "model User" command from the shell. i get an

" driver not found"

with MAMP in Leopard.

The PDO extension are ok

My connection string is







Did you check this? http://www.yiiframew…doc/cookbook/7/

I have try with as suggest but an error occur

imac-di-andrea-bersi:testdrive abmcr$ php -c /Applications/MAMP/conf/php5/php.ini /Applications/MAMP/htdocs/testdrive/protected/yiic.php shell

dyld: NSLinkModule() error

dyld: Library not loaded: /Users/severin/Dev/Projects/MAMP_1.7_src/lib/libltdl.3.dylib

  Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/

  Reason: image not found

Trace/BPT trap


Disable these extensions then (in your php.ini) They are not crucial.

Ok thank you: all work fine now. I continue my tutorial