如何获取SQLite中的最后一个插入ID? [英] How to get last insert Id in SQLite?

查看:704
本文介绍了如何获取SQLite中的最后一个插入ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQLite中是否有可用的内置函数来获取最后插入的行ID。
例如: - 在mysql中,我们有 LAST_INSERT_ID()这种函数。对于sqllite,任何可用于执行相同过程的功能都可用。



请帮助我。



谢谢

解决方案

SQLite



这可以使用 SQLite last_insert_rowid()函数


last_insert_rowid()函数返回从调用该函数的数据库连接插入的最后一行
的ROWID。
last_insert_rowid()SQL函数是
sqlite3_last_insert_rowid()C / C ++接口函数的一个包装。



PHP



这个函数的PHP版本/绑定是
lock $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b

返回最近插入到
数据库dbhandle中的行的rowid,如果它创建为自动增量字段。



Is there any built in function available in SQLite to fetch last inserted row id. For eg :- In mysql we have LAST_INSERT_ID() this kind of a function. For sqllite any function available for doing the same process.

Please help me.

Thanks

解决方案

SQLite

This is available using the SQLite last_insert_rowid() function:

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function.

PHP

The PHP version/binding of this function is sqlite_last_insert_rowid():

Returns the rowid of the row that was most recently inserted into the database dbhandle, if it was created as an auto-increment field.

这篇关于如何获取SQLite中的最后一个插入ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆