Answer the question
In order to leave comments, you need to log in
How to determine the id of the created model in afterSave()?
Greetings! $this->id
why is it empty. $this->name is defined. Yii::app()->db->getLastInsertID();
gives an error:
SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax
Answer the question
In order to leave comments, you need to log in
If $this->id is empty, then the entry was not saved, in the controller do echo $model->save(); (to check if saving happened) and then if there is no saving - print_r($model->getErrors()); (this will show validation errors). Well, you can also see what request is going through in the debug panel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question