Getting last inserted value in Yii(在 Yii 中获取最后插入的值)
本文介绍了在 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 中获取最后插入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在 Yii 中获取最后插入的值
基础教程推荐
猜你喜欢
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01