我有一个表,其中auto_incrementing列被设置为主键。是否可以在使用活动记录插入后从此列中获取数字而无需运行其他查询?
$payment = new Model\Payment;
$payment->userId = $userId;
$payment->item = $item;
$payment->state = 'I';
$ insert_id =
$payment->save();
答案 0 :(得分:6)
$payment->save();
$insert_id = $payment->id;