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

查看:77
本文介绍了在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

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

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.

推荐答案

您可以像这样获得最后插入的ID:

You can get the last inserted ID like this:

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

有关更多信息,请参见 Yii文档.

See the Yii documentation for more information.

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

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