开发者

Get ID of newly created document

开发者 https://www.devze.com 2023-04-12 05:11 出处:网络
I am working with MongoDB and Codeignite开发者_如何学Cr (and Alex Bilbies MongoDB library) and I am just wondering. Is there a way to get the ID of the post I create below directly after?

I am working with MongoDB and Codeignite开发者_如何学Cr (and Alex Bilbies MongoDB library) and I am just wondering. Is there a way to get the ID of the post I create below directly after?

$this->CI->mongo_db->insert('oauth_sessions', array('client_id' => $client_id, 'redirect_uri' => $redirect_uri, 'user_id' => $user_id, 'code' => $code, 'first_requested' => time(), 'last_updated' => time()));

Thankful for all input!


You should be able to get this by the CI standard db function insert_id().

So directly after your Insert call

do

$iLastInsertedID=$this->CI->mongo_db->insert_id();
0

精彩评论

暂无评论...
验证码 换一张
取 消