mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
feat(AbstractDb): supports MySql backend for last insert id
This commit is contained in:
parent
531e3d1b8c
commit
1710cece1a
1 changed files with 15 additions and 12 deletions
|
|
@ -91,21 +91,24 @@ string AbstractDb::primaryKeyAutoIncrementStr (const string &type) const {
|
|||
}
|
||||
|
||||
long AbstractDb::getLastInsertId () const {
|
||||
L_D();
|
||||
|
||||
string sql;
|
||||
switch(d->backend) {
|
||||
case Sqlite3:
|
||||
sql = "SELECT last_insert_rowid()";
|
||||
break;
|
||||
default:
|
||||
lWarning() << "Unsupported backend.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
long result = 0;
|
||||
|
||||
#ifdef SOCI_ENABLED
|
||||
L_D();
|
||||
|
||||
string sql;
|
||||
switch (d->backend) {
|
||||
case Mysql:
|
||||
sql = "SELECT LAST_INSERT_ID()";
|
||||
break;
|
||||
case Sqlite3:
|
||||
sql = "SELECT last_insert_rowid()";
|
||||
break;
|
||||
default:
|
||||
lWarning() << "Unsupported backend.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
*session << sql, soci::into(result);
|
||||
#endif // ifdef SOCI_ENABLED
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue