lundi 3 août 2015

How to fetch data from sqlite3 without using while 1 and if

I'm currently using this method of fetching data from sqlite3 database:

while(1){
   rc = sqlite3_step(stmt);
   if(rc == SQLITE_ROW){
       ...
   }
   else if(rc == SQLITE_DONE){
       break;
   }
}

What I do not like about this is if else construct, which looks rather clunky here. And besides, everyone knows that if else is evil. So, probably there is another method of fetching data from sqlite, something like:

while(sqlite3_step(stmt)){
   ...
}

Or, probably, there is a fetch method or something similar to that.

I just want to know what other people do in real world projects.

Aucun commentaire:

Enregistrer un commentaire