在 Yii 中获取最后插入的值 [英] Getting last inserted value in Yii

查看:25
本文介绍了在 Yii 中获取最后插入的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为表单做了一个模型.因为字段就像

id名姓描述created_at更新时间由...制作更新者

我已经为表单做了必要的 CRUD.现在我想为视图文件中最后插入的 id 获取一个额外的字段.那么如何获取该值?要获取该值,我应该在 CRUD 中进行任何必要的更改吗?任何帮助和建议将非常实用.

解决方案

你可以像这样获取最后插入的 ID:

Yii::app()->db->getLastInsertId();

有关详细信息,请参阅 Yii 文档.>

I have already made a model for form.In that the fields were like

id
firstname
lastname
description
created_at
updated_at
created_by
updated_by

I have made necessary CRUD for Form.Now I want to get one extra field for last inserted id in view file.So how to get that value?To get that value should I make any necessary changes in CRUD?Any help and suggestions will be highly appriciable.

解决方案

You can get the last inserted ID like this:

Yii::app()->db->getLastInsertId();

See the Yii documentation for more information.

这篇关于在 Yii 中获取最后插入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆