Hello, you can also do this:
In your Controller User:
Code:
var $ uses = array ('User', 'Artist');
Thus, you can directly use the two models in the same controller ... You do not have to create a controller for model. And to retrieve the id of a new record, you can do this:
Code:
if ($ this-> User-> save ($ this-> data ['User']))
{
$ User_id = $ this-> User-> getInsertID ();
//...
}
That is, if it can be useful to you. The method getInsertID () is deprecated for a while, instead using the technique described by Rixwel above, ie $this->User->id; which always contains the id of the last record. Also, yes you can add all the models in $uses , but this is not a good practice because it includes unnecessary overload achieved. It should do so only for models with no relationship between them, otherwise we use the winner chaining of models:
$this->Model->OtherModel->find()
Bookmarks