Get ID of newly created document
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();
精彩评论