调用ActiverEcord Save()方法Prado之后,如何获取主键?
-
30-09-2019 - |
题
我从Prado PHP框架开始,我有一个快速的问题:如何获取最后插入记录的主要键?我的代码如下:
$studentRecord = new StudentRecord;
$studentRecord->Name = $this->txtName->SafeText;
$studentRecord->ContactNumber = $this->txtContactNo->SafeText;
$studentRecord->save();
// $studentId = ???
谢谢!
解决方案
我不使用prado,但通常使用主动记录模式实现,保存后对象会刷新。做 $record->id
(或您的PK Col是什么)不起作用?
不隶属于 StackOverflow