Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. sqlite3 *database;
  2.         NSMutableArray *array = [[NSMutableArray alloc] init];
  3.         if(sqlite3_open([[self databasePath] UTF8String], &database) == SQLITE_OK) {
  4.                 NSString *stmt = [NSString stringWithFormat:@"select * from horses WHERE racetime='%@' ORDER BY number ASC;",race];
  5.                 char statement[55];
  6.                 [stmt getCString:statement];
  7.                 sqlite3_stmt *compiledStatement;
  8.                 if(sqlite3_prepare_v2(database, statement, -1, &compiledStatement, NULL) == SQLITE_OK) {
  9.                         while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
  10.                                 NSMutableString *horse = [[NSMutableString alloc] initWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
  11.                                 NSString *name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
  12.                                 [horse appendFormat:@". %@", name];
  13.                                 [array addObject:horse];
  14.                                 [horse release];
  15.                         }
  16.                 }
  17.         }
  18.         sqlite3_close(database);
  19.         return array;