@@ -99,12 +99,8 @@ class clsDb {
9999 int n = columns.size ();
100100 for (int i = 1 ; i < n; i++) command += ' ,' + columns[i];
101101 command += " from " + table;
102-
103- if (!condition.empty ())
104- command += " where " + condition + ' ;' ;
105- else
106- command += ' ;' ;
107- cout << command << endl;
102+ if (!condition.empty ()) command += " where " + condition;
103+ command += ' ;' ;
108104
109105 sqlite3_stmt *stmt;
110106 sqlite3_prepare_v2 (db, command.c_str (), -1 , &stmt, 0 );
@@ -186,11 +182,13 @@ int main(int argc, char *argv[]) {
186182 genSha256Hash (" kurwa" , hash);
187183 // db.insert("users", {"username", "password"}, "bober", sizeof(hash),
188184 // hash);
185+ unsigned long id = 0 ;
189186 string username;
190187 char password[SHA256_DIGEST_LENGTH];
191- db.select (" users" , {" username" , " password" }, " id = ? " , 1 , &username,
192- sizeof (password), &password);
193- cout << username << ' |' << password << endl;
188+ string con = " kurwa" ;
189+ db.select (" users" , {" id" , " username" , " password" }, " username = ?" ,
190+ con.c_str (), &id, &username, sizeof (password), &password);
191+ cout << id << ' |' << username << ' |' << password << endl;
194192}
195193// insert into users (username, password) values (?, ?);
196194// update projects set dirTree = ? where id = ?;
0 commit comments