why new model's id is null

$model = new Somemodel();

$model->attributes = $_POST[‘Somemodel’];


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:


Are you sure that your model really saved? Try this:

if ($model->save())



  exit('model not saved');