fix binding faction.no to sqlite statement.

This commit is contained in:
Enno Rehling 2019-04-26 23:54:22 +02:00
parent 71090d0091
commit cffcac8af7
1 changed files with 8 additions and 1 deletions

View File

@ -100,13 +100,20 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha
{ {
dbrow_id id = *p_id; dbrow_id id = *p_id;
int err; int err;
char dbno[4];
size_t len;
const char *str;
sqlite3_stmt *stmt = (id > 0) ? g_stmt_update_faction : g_stmt_insert_faction; sqlite3_stmt *stmt = (id > 0) ? g_stmt_update_faction : g_stmt_insert_faction;
assert(g_game_db); assert(g_game_db);
err = sqlite3_reset(stmt); err = sqlite3_reset(stmt);
if (err != SQLITE_OK) return err; if (err != SQLITE_OK) return err;
err = sqlite3_bind_text(stmt, 1, itoa36(no), -1, SQLITE_STATIC); str = itoa36(no);
len = strlen(str);
assert(len <= 4);
memcpy(dbno, str, len);
err = sqlite3_bind_text(stmt, 1, dbno, len, SQLITE_STATIC);
if (err != SQLITE_OK) return err; if (err != SQLITE_OK) return err;
err = sqlite3_bind_text(stmt, 2, email, -1, SQLITE_STATIC); err = sqlite3_bind_text(stmt, 2, email, -1, SQLITE_STATIC);
if (err != SQLITE_OK) return err; if (err != SQLITE_OK) return err;