当前位置: 首页 > 知识库问答 >
问题:

如何获取10月CMS模型的上次添加id?[副本]

隗昀
2023-03-14
        $doc->user_id = Auth::getUser()->id;;
        $doc->type = post('type');
        $doc->list_num = post('list_num');
        $doc->ticket = post('ticket');
        $doc->contract = post('contract');
        $doc_id = $doc->save();

我想从数据库中获取上次添加的modele id。我怎么能这么做?

共有1个答案

仇航
2023-03-14
...
$doc_id = $doc->save();
$doc_id  = $doc->id; //id is the primary id you set in model, default is id
 类似资料: