活动记录最后一次插入ID

时间:2012-11-24 10:26:18

标签: php activerecord

我有一个表,其中auto_incrementing列被设置为主键。是否可以在使用活动记录插入后从此列中获取数字而无需运行其他查询?

$payment = new Model\Payment;
$payment->userId = $userId;
$payment->item = $item;
$payment->state = 'I';
  

$ insert_id =

$payment->save();

1 个答案:

答案 0 :(得分:6)

$payment->save();
$insert_id = $payment->id;