已先使用FMDB读取sqlite的某一table J的值
程式:
NSMutableArray* JData = [NSMutableArray arrayWithCapacity: 0];
FMResultSet *rs = [db executeQuery: @"SELECT uid, uidY, uidH, uidT, uidO from J"];
while ([rs next]) {
int uid = [rs intForColumn: @"uid"];
int uidY = [rs intForColumn: @"uidY"];
int uidH = [rs intForColumn: @"uidH"];
int uidT = [rs intForColumn: @"uidT"];
int uidO = [rs intForColumn: @"uidO"];
[JData addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: uid], @"uid",
[NSNumber numberWithInt: uidY], @"uidY",
[NSNumber numberWithInt: uidH], @"uidH",
[NSNumber numberWithInt: uidT], @"uidT",
[NSNumber numberWithInt: uidO], @"uidO",
nil]];
}
NSLog(@"%@", JData[2]);
结果:
uid = 3;
uidH = 0;
uidO = 3;
uidT = 0;
uidY = 98;
程式设计的目的:
读取table J的值转成二维阵列
以便直接读取特定位置的值进行运算
请问:
1. 输出结果顺序与读取顺序不同,应如何修正?
读取sqlite的table J字段顺序:uid, uidY, uidH, uidT, uidO
但显示读取后的字段值顺序却是:uid, uidH, uidO, uidT, uidY
2. 如何读取特定位置的值?
数据库就像二维阵列
虽然可以读取某列的值(如:JData[2]列出uid, uidH, uidO, uidT, uidY)
但要如何读取某列某行的值(如:JData[2][2])
谢谢