开发者

return id of new record

Is there a way with Pear DB to 开发者_开发问答return the ID of a newly INSERTED record?


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.


Does this work?

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


Not really answering your question as such but the DB package has been deprecated for a very long time - you are better off to be using the MDB2 package which is actively maintained - the latest release was last month.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜