老师,为什么我select * from 表名,不能查询表的全部内容啊??
老师,为什么我select * from 表名,不能查询表的全部内容啊??只能查询前两行。这是为什么啊
老师,为什么我select * from 表名,不能查询表的全部内容啊??只能查询前两行。这是为什么啊
2016-10-19
// 查询
- (NSMutableArray *)search{
NSMutableArray *array = [NSMutableArray array];
NSString *path = [self applicationDocumentsDirectoryFile];
if (sqlite3_open([path UTF8String], &db) != SQLITE_OK) {
sqlite3_close(db);
NSAssert(NO, @"数据库打开失败!");
} else {
NSString *qsql = @"SELECT * FROM StudentName";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(db, [qsql UTF8String], -1, &statement, NULL) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *idNum = (char *)sqlite3_column_text(statement, 0);
NSString *ageStr = [[NSString alloc]initWithUTF8String:idNum];
char *name = (char *)sqlite3_column_text(statement, 1);
NSString *nameStr = [NSString stringWithUTF8String:name];
StudentModel *model = [[StudentModel alloc]init];
model.age = ageStr;
model.name = nameStr;
[array addObject:model];
}
sqlite3_finalize(statement);
sqlite3_close(db);
}
// sqlite3_finalize(statement);
// sqlite3_close(db);
return array;
}
return nil;
}
举报