Explorar o código

Here's how to do case insensitve search. (If you need to)

Steve Thielemann %!s(int64=4) %!d(string=hai) anos
pai
achega
cdc188807f
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      dataplay.c

+ 5 - 2
dataplay.c

@@ -29,9 +29,12 @@ void datado(void) {
   // for now
 
   // NEXT!
-  char nick[] = "Captain";
+  char nick[] = "captain";
+
+  // https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing#973785
+  strcpy(sqlbuffer, "SELECT id FROM USER WHERE nick=? COLLATE NOCASE");
+  // captain will now match Captain
 
-  strcpy(sqlbuffer, "SELECT id FROM USER WHERE nick=?");
   sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL);
   sqlite3_bind_text(stmt, 1, nick, strlen(nick), SQLITE_STATIC);
   rc = sqlite3_step(stmt);