This is how we bind sqlite variables by index.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4576 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -55,7 +55,7 @@ static bool _tf_ssb_connections_get_next_connection(tf_ssb_connections_t* connec
|
||||
bool result = false;
|
||||
sqlite3_stmt* statement;
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(connections->ssb);
|
||||
if (sqlite3_prepare(db, "SELECT host, port, key FROM connections WHERE last_attempt IS NULL OR (strftime('%s', 'now') - last_attempt > $1) ORDER BY last_attempt LIMIT 1", -1, &statement, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare(db, "SELECT host, port, key FROM connections WHERE last_attempt IS NULL OR (strftime('%s', 'now') - last_attempt > ?1) ORDER BY last_attempt LIMIT 1", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_int(statement, 1, 60000) == SQLITE_OK &&
|
||||
sqlite3_step(statement) == SQLITE_ROW)
|
||||
@ -181,7 +181,7 @@ static void _tf_ssb_connections_update_work(uv_work_t* work)
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(update->ssb);
|
||||
if (update->attempted)
|
||||
{
|
||||
if (sqlite3_prepare(db, "UPDATE connections SET last_attempt = strftime('%s', 'now') WHERE host = $1 AND port = $2 AND key = $3", -1, &statement, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare(db, "UPDATE connections SET last_attempt = strftime('%s', 'now') WHERE host = ?1 AND port = ?2 AND key = ?3", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, update->host, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_int(statement, 2, update->port) == SQLITE_OK &&
|
||||
@ -197,7 +197,7 @@ static void _tf_ssb_connections_update_work(uv_work_t* work)
|
||||
}
|
||||
else if (update->succeeded)
|
||||
{
|
||||
if (sqlite3_prepare(db, "UPDATE connections SET last_success = strftime('%s', 'now') WHERE host = $1 AND port = $2 AND key = $3", -1, &statement, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare(db, "UPDATE connections SET last_success = strftime('%s', 'now') WHERE host = ?1 AND port = ?2 AND key = ?3", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, update->host, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_int(statement, 2, update->port) == SQLITE_OK &&
|
||||
@ -213,7 +213,7 @@ static void _tf_ssb_connections_update_work(uv_work_t* work)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sqlite3_prepare(db, "INSERT INTO connections (host, port, key) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING", -1, &statement, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare(db, "INSERT INTO connections (host, port, key) VALUES (?1, ?2, ?3) ON CONFLICT DO NOTHING", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, update->host, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_int(statement, 2, update->port) == SQLITE_OK &&
|
||||
|
Reference in New Issue
Block a user