Hi guys,
I'm having some trouble getting Yii to work with MySQL on my MAMP box. I have in my main.php:
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:localhost;dbname=testdb;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock',
'username'=>'username',
'password'=>'password',
),
Then I run:
/Applications/MAMP/bin/php5/bin/php …/yii/framework/yiic shell
I type: model User
And I get:
>> model User
Warning: the table 'User' does not exist in the database.
unchanged User.php
When trying crud User I get:
>> crud User
exception 'CDbException' with message 'The table "User" for active record class "User" cannot be found in the database.' in /Applications/MAMP/htdocs/yii/framework/db/ar/CActiveRecord.php:1569
Stack trace:
#0 /Applications/MAMP/htdocs/yii/framework/db/ar/CActiveRecord.php(436): CActiveRecordMetaData->__construct(Object(User))
#1 /Applications/MAMP/htdocs/yii/framework/cli/commands/shell/CrudCommand.php(102): CActiveRecord::model('User')
#2 /Applications/MAMP/htdocs/yii/framework/console/CConsoleCommand.php(116): CrudCommand->generateController('/Applications/M…', Array)
#3 /Applications/MAMP/htdocs/yii/framework/cli/commands/shell/CrudCommand.php(93): CConsoleCommand->copyFiles(Array, '/Applications/M…', Array)
#4 /Applications/MAMP/htdocs/yii/framework/cli/commands/ShellCommand.php(98): CrudCommand->run(Array)
#5 /Applications/MAMP/htdocs/yii/framework/cli/commands/ShellCommand.php(78): ShellCommand->runShell(Array)
#6 /Applications/MAMP/htdocs/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run()
#7 /Applications/MAMP/htdocs/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#8 /Applications/MAMP/htdocs/yii/framework/base/CApplication.php(146): CConsoleApplication->processRequest(Array)
#9 /Applications/MAMP/htdocs/yii/framework/yiic.php(30): CApplication->run()
#10 /Applications/MAMP/htdocs/yii/framework/yiic(15): require_once('/Applications/M…')
#11 {main}
MySQL is up and running and I have a database named testdb with a table User created like this:
CREATE TABLE testdb
.User
(
id
INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username
VARCHAR( 128 ) NOT NULL ,
password
VARCHAR( 128 ) NOT NULL ,
email
VARCHAR( 128 ) NOT NULL
) ENGINE = MYISAM
Can anyone tell me why it's not working?