调用ActiveRecord save()方法PRADO后如何获取主键?

发布于 2024-09-15 19:05:13 字数 308 浏览 2 评论 0原文

我开始使用 PRADO php 框架,我有一个简单的问题:如何获取最后插入记录的主键?我的代码如下:

$studentRecord = new StudentRecord;
$studentRecord->Name = $this->txtName->SafeText;
$studentRecord->ContactNumber = $this->txtContactNo->SafeText;
$studentRecord->save();
// $studentId = ???

谢谢!

I am starting out with PRADO php framework and i have a quick question: How to get the Primary Key of the last inserted record? My codes are as follow:

$studentRecord = new StudentRecord;
$studentRecord->Name = $this->txtName->SafeText;
$studentRecord->ContactNumber = $this->txtContactNo->SafeText;
$studentRecord->save();
// $studentId = ???

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独木成林 2024-09-22 19:05:13

我不使用 Prado,但通常使用 Active Record 模式实现,对象在保存时会刷新。 $record->id (或者你的 pk col 是什么)不起作用吗?

I don't use Prado but normally with Active Record pattern implementations the objects are refreshed when saved. Does $record->id (or whatever your pk col is) not work?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文