I can't save my model with the console. If I copy the code to a controller it works. I also copied my main.php to console.php so I don't believe it is my settings. I am using PostgreSQL. Anyone have any ideas? It is complaining about the Boolean values.
This is the error I get:
<?php class FieldCommand extends CConsoleCommand { public function getHelp() { $description = "DESCRIPTION\n"; $description .= ' '."This command creates Fields .\n"; return parent::getHelp() . $description; } public function actionIndex() { $model=new Field; $model->field_id = 34; $model->name = 'TEST'; $model->type = 1; $model->tag = 'SYSTEM'; $model->active = TRUE; $model->display = TRUE; $model->brand = "{}"; $model->weight = 0; if(!$model->save()) echo CHtml::errorSummary($model); echo "failed \n"; } }
This is the error I get:
./yiic field exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "active" is of type boolean but expression is of type integer LINE 1: ...ay", "brand") VALUES (0, 34, 'TEST', 1, 'SYSTEM', 1, 1, '{}'... ^ HINT: You will need to rewrite or cast the expression.. The SQL statement executed was: INSERT INTO "field" ("weight", "field_id", "name", "type", "tag", "active", "display", "brand") VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7)' in /Applications/MAMP/htdocs/leadworks/framework/db/CDbCommand.php:357 Stack trace: #0 /Applications/MAMP/htdocs/leadworks/framework/db/ar/CActiveRecord.php(1023): CDbCommand->execute() #1 /Applications/MAMP/htdocs/leadworks/framework/db/ar/CActiveRecord.php(795): CActiveRecord->insert(NULL) #2 /Applications/MAMP/htdocs/leadworks/leadworks/protected/commands/FieldCommand.php(22): CActiveRecord->save() #3 [internal function]: FieldCommand->actionIndex() #4 /Applications/MAMP/htdocs/leadworks/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(FieldCommand), Array) #5 /Applications/MAMP/htdocs/leadworks/framework/console/CConsoleCommandRunner.php(67): CConsoleCommand->run(Array) #6 /Applications/MAMP/htdocs/leadworks/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array) #7 /Applications/MAMP/htdocs/leadworks/framework/base/CApplication.php(169): CConsoleApplication->processRequest() #8 /Applications/MAMP/htdocs/leadworks/framework/yiic.php(33): CApplication->run() #9 /Applications/MAMP/htdocs/leadworks/leadworks/protected/yiic.php(7): require_once('/Applications/M...') #10 /Applications/MAMP/htdocs/leadworks/leadworks/protected/yiic(4): require_once('/Applications/M...') #11 {main}Alberts-MacBook-Air:protected albertski$