| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // HistoryData.m
- // Apex Mobile
- //
- // Created by Ray on 14-4-24.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "HistoryData.h"
- @implementation HistoryData
- -(long) get_count
- {
- return self.pagedata.count;
- }
- - (id)init
- {
- self = [super init];
- if (self) {
- self.pagedata =[[NSMutableArray alloc]init];
-
- ApexMobileAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
- // NSString* required_ver=[objheader objectForKey:@"client_ver"] ;
- //
- // appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
- // appDelegate.user = user;
- // appDelegate.password = password;
-
- sqlite3 *db =[ApexMobileDB get_db];
- NSString *quary = [NSString stringWithFormat:@"select _id,create_time,params,module_name,name from history where user='%@' order by _id desc",appDelegate.user];
-
-
-
- sqlite3_stmt *stmt;
- if (sqlite3_prepare_v2(db, [quary UTF8String], -1, &stmt, nil) == SQLITE_OK) {
- DebugLog(@"sql:%@",quary);
- while (sqlite3_step(stmt)==SQLITE_ROW)
- {
- // NSString *aname = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 0)];
- int _id = sqlite3_column_int(stmt, 0);
- // NSString* str_time = sqlite3
- NSString* create_time = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 1)];
- NSString* params =[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 2)];
- NSString* module_name =[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 3)];
-
- NSString* name =[NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 4)];
- NSMutableDictionary * map = [[NSMutableDictionary alloc] init];
- [map setValue:[NSString stringWithFormat:@"%d",_id] forKey:@"_id"];
- [map setValue:[NSString stringWithFormat:create_time,create_time] forKey:@"create_time"];
- [map setValue:params forKey:@"params"];
- [map setValue:module_name forKey:@"module_name"];
- [map setValue:name forKey:@"name"];
-
- [self.pagedata addObject:map];
-
-
- }
-
- sqlite3_finalize(stmt);
- }
- //用完了一定记得关闭,释放内存
- sqlite3_close(db);
-
- }
- return self;
- }
- @end
|