$model = new Somemodel();
$model->attributes = $_POST[‘Somemodel’];
$model->save();
why $model->id is null?
how can I get new record id ?
$model = new Somemodel();
$model->attributes = $_POST[‘Somemodel’];
$model->save();
why $model->id is null?
how can I get new record id ?
The attribute is usually filled when it is autoincrement.
Can you show your sql for create table?
i also could not get the id of the model by this way although my id is auto increment and primary key on db side then i used this one:
$model->getPrimaryKey();
Are you sure that your model really saved? Try this:
if ($model->save())
exit($model->id);
else
exit('model not saved');