我从Prado PHP框架开始,我有一个快速的问题:如何获取最后插入记录的主要键?我的代码如下:

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

谢谢!

有帮助吗?

解决方案

我不使用prado,但通常使用主动记录模式实现,保存后对象会刷新。做 $record->id (或您的PK Col是什么)不起作用?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top