//判断字段是否存在
if ([self.db columnExists:kScanCardPath inTableWithName:TABLE_CARD]) {
NSString *update = [NSString stringWithFormat:@"UPDATE %@ SET %@=? WHERE %@ = '%@'",TABLE_CARD,kScanCardPath,kLiuDuID,liuduid];
[self.db executeUpdate:update,path];
}else{
NSString *sql = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ text",TABLE_CARD,kScanCardPath];
[self.db executeUpdate:sql];
NSString *update = [NSString stringWithFormat:@"UPDATE %@ SET %@=? WHERE %@ = '%@'",TABLE_CARD,kScanCardPath,kLiuDuID,liuduid];
[self.db executeUpdate:update,path];
}
kScanCardPath,kLiuDuID<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">是字段的宏定义</span>
TABLE_CARD<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">是表名的宏定义</span>
注意:需包含头文件#import"FMDatabaseAdditions.h"