Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table if not exists t_user (
- username text,
- password text
- );
- bool Foo(const QString &username, const QString &password)
- {
- int res = 0;
- sqlite3_stmt *stmt = NULL;
- const char sql[] = "select count(username) from t_user where username = ? and password = ?;";
- res = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);//res == SQLITE_OK
- res = sqlite3_bind_text(stmt, 1, username.toUtf8().data(), username.toUtf8().size(), NULL);//res == SQLITE_OK
- res = sqlite3_bind_text(stmt, 2, password.toUtf8().data(), password.toUtf8().size(), NULL);//res == SQLITE_OK
- res = sqlite3_step(stmt);//res == SQLITE_ROW
- res = sqlite3_column_int(stmt, 0);
- sqlite3_finalize(stmt);
- return res > 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement