Yii::app()->db->getLastInsertId();
2、If $model->id wouldn't work then use Yii::app()->db->getLastInsertId() or getPrimaryKey()
3、If your goal is to get the id that was assigned to the model that you just saved,
then after you do $model->save(), simply do $model->id to get it back.
4、
you can also get the last inserted id of another model.