Home >PHP Framework >YII >How to get the new data id in yii

How to get the new data id in yii

angryTom
angryTomOriginal
2020-02-17 09:40:482771browse

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

How to get the new data id in yii

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn