09.04.2014, 19:29
(
Последний раз редактировалось Baltazar; 09.04.2014 в 20:00.
)
How do I get row-id of a just-inserted row on SQLite?
qresult = db_query(sqlite, "SELECT LAST_INSERT_ID()");
cache_insert_id after a query (mysql_(p/t)query, doesn't matter), if you want to use it in a INSERT query.
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_insert_id |
UPDATE `tableName` SET Just_insert = 0;
INSERT INTO `tableName` (fieldName1,...fieldNameN,Just_insert) VALUES('value1',..'valueN',1)
SELECT `rowid` from `tableName` WHERE `Just_insert`=1;
My mistake, sorry. Umm... you could also use MySQL, it is pretty much the same thing, and it is better.
![]() |
stock db_insert(DB:db, const szQuery[]) {
new
DBResult:dbrResult = db_query(db, szQuery, false)
;
if (dbrResult) {
db_free_result(dbrResult);
return db_last_insert_rowid(db);
}
return 0;
}
There is a feature in sqlitei to do this.
https://sampforum.blast.hk/showthread.php?tid=303682 db_last_insert_rowid(DB:db) HOWEVER I tried using this once and it was crashing my server I'll ask Slice if he can fix this issue. |