简体   繁体   中英

return id of new record

Pear DB是否有办法返回新插入的记录的ID?

Yes, last_insert_id() is the answer to your question. It's session specific, so you don't have to worry if the id returned is the id from another row inserted by another user. You will be sure it's the one you need.

这样行吗?

$id = $db->getOne('SELECT LAST_INSERT_ID()');

不能真正回答您的问题,但是DB软件包已被弃用很长时间了-您最好使用主动维护的MDB2软件包-最新版本是上个月。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM