Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. create table if not exists t_user (
  2. username text,
  3. password text
  4. );
  5.  
  6. bool Foo(const QString &username, const QString &password)
  7. {
  8. int res = 0;
  9. sqlite3_stmt *stmt = NULL;
  10. const char sql[] = "select count(username) from t_user where username = ? and password = ?;";
  11. res = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);//res == SQLITE_OK
  12.  
  13. res = sqlite3_bind_text(stmt, 1, username.toUtf8().data(), username.toUtf8().size(), NULL);//res == SQLITE_OK
  14. res = sqlite3_bind_text(stmt, 2, password.toUtf8().data(), password.toUtf8().size(), NULL);//res == SQLITE_OK
  15.  
  16. res = sqlite3_step(stmt);//res == SQLITE_ROW
  17. res = sqlite3_column_int(stmt, 0);
  18.  
  19. sqlite3_finalize(stmt);
  20. return res > 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement