//增
-(void)insertStudent:(Student *)student
{
//准备插入语句,因为student表里的number设置的是自增,所以可以不用再次设置。
NSString *insertsql = [NSString stringWithFormat:@"INSERT INTO 'student' (name,age,gender) VALUES ('%@','%ld','%@')",student.name,student.age,student.gender];
//开始执行
int result = sqlite3_exec(db,insertsql.UTF8String,NULL,NULL);
if (sqlITE_OK == result) {
NSLog(@"插入成功");
}else
{
NSLog(@"插入失败");
}
}
原文链接:https://www.f2er.com/sqlite/199301.html