These methods are missing in the tutorial version of the Lookup model (/webroot/protected/models/Lookup.php)
/**
* Returns the static model of the specified AR class.
* @return CActiveRecord the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return '{{lookup}}';
}
Thanks I’m also running through the blog tutorial, and had run into the same problem. The tutorial is a bit broken in places - on the other hand you learn a darn site more when you actually have to dig around and figure out why it isn’t working.
For what it’s worth (buggy tutorial not withstanding) I am really enjoying playing with Yii - there are some lovely ideas.
I have had the same problem so far. I followed initially the basic tutorial from Larry Ullman but now I wanted to learn more about YII with the Blog Tutorial that looks a bit broken.
I have tried to complete it twice and now the second time I am getting a constraint error on the DB
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`XXXXXX_yiitest`.`tbl_post`, CONSTRAINT `FK_post_author` FOREIGN KEY (`author_id`) REFERENCES `tbl_user` (`id`) ON DELETE CASCADE)
The above is really strange as I have got the relation between author id and user->id expressed in my rules.
Is there a way in YII to actually check what is the actual SQL query/statement that the system has tried to run?
My next attempt will be with the full online guide and a book … I hope they are less confusing
If the Blog tutorial gets updated I am definitelly interested to hear about it
In the config file of the application you generated with yiic, you will find a CFileLogroute already defined for you, just to uncomment. The log file will be protected/runtime/application.log. To enable logging of the actual SQL parameters, add enableParamLogging=>true to the db component.
I get the exact same error as Bizmate and am unable to find the problem. The log file provides no more information regarding the raw SQL than what was provided in Bizmate’s post.
If you get the error "foreign key constraint" while trying to add some new records to a table… it means that you are trying to add a value to the foreign key that does not exist in the related table…
For example lets say that you want to add a record to the posts table… and for the author_id you are trying to add the value 2… if in the author table there is no record with the id 2… you will get this error…