garten

diff db.c @ 17:5e6c9260913a

lots of cleanups and small fixes
author meillo@marmaro.de
date Wed, 23 Jul 2008 17:14:38 +0200
parents 3c104b5f5158
children 5937504619f2
line diff
     1.1 --- a/db.c	Wed Jul 23 16:49:10 2008 +0200
     1.2 +++ b/db.c	Wed Jul 23 17:14:38 2008 +0200
     1.3 @@ -45,6 +45,18 @@
     1.4  }
     1.5  
     1.6  
     1.7 +int db_rows(sqlite3_stmt* stmt) {
     1.8 +	int i = 0;
     1.9 +
    1.10 +	sqlite3_reset(stmt);
    1.11 +	while (sqlite3_step(stmt) == SQLITE_ROW) {
    1.12 +		i++;
    1.13 +	}
    1.14 +	sqlite3_reset(stmt);
    1.15 +	return i;
    1.16 +}
    1.17 +
    1.18 +
    1.19  int read_time() {
    1.20  	sprintf(query, "select time from game;");
    1.21  	stmt = db_query(query);
    1.22 @@ -57,3 +69,7 @@
    1.23  	return gametime;
    1.24  }
    1.25  
    1.26 +
    1.27 +void db_error(char* info) {
    1.28 +	fprintf(stderr, "%s%sSQL error: %s\n", (info) ? info : "", (info) ? ": " : "", sqlite3_errmsg(db));
    1.29 +}