您好,登录后才能下订单哦!
打开数据库
sqlite3 * db = [Database openDB];
sqlite3_stmt * stmt = nil;
NSString * sqlString = [NSString stringWithFormat:@"select * from Student where id = %d" , aID];
int result = sqlite3_prepare_v2(db, [sqlString UTF8String], -1, &stmt,NULL);
Student * student = nil;
if (result == SQLITE_OK) {
if (sqlite3_step(stmt) == SQLITE_ROW) {
int ID = sqlite3_column_int(stmt, 0);
const unsigned char * name = sqlite3_column_text(stmt, 1);
const unsigned char * gender = sqlite3_column_text(stmt ,2);
int age = sqlite3_column_int(stmt, 3);
int lenght = sqlite3_column_bytes(stmt, 4);
const void * photo = sqlite3_column_blob(stmt, 4);
NSData * photoData = [NSData dataWithBytes:photo length:lenght];
UIImage * p_w_picpath = [UIImage p_w_picpathWithData:photoData];
student = [[Student alloc]init];
student.ID = ID;
student.name = [NSString stringWithUTF8String:(const char *)name];
student.gender = [NSString stringWithUTF8String:(const char *)gender];
student.age = age;
student.photo = p_w_picpath;
}
}
sqlite3_finalize(stmt);
[Database closeDB];
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。