Home >PHP Framework >YII >How to get the new data id in yii
How does yii get the newly added data id
//提交过来的数据 $post = Yii::$app->request->post(); //实例化对象 $model = new User(); $model->setAttributes($post); if($model->validate()){ $model->save(); } //成功后获取该记录主键 id var_dump($model->id);
If not obtained View models
Related article tutorial recommendations:yiiTutorial
Just remove the defined primary key id.
The above is the detailed content of How to get the new data id in yii. For more information, please follow other related articles on the PHP Chinese website!