ios将图片存入数据库

0             NSData * imgData = UIImagePNGRepresentation ([UIImage imageWithContentsOfFile:filePath]);
07              const   char * sequel = “insert into test_table(name,image) values(?,?)”;
08
09              sqlite3_stmt * update;
10              if (sqlite3_prepare_v2(database, sequel, -1, &update, NULL) == SQLITE_OK)
11              {
12                      sqlite3_bind_text(update, 1, name, -1, NULL);
13                      sqlite3_bind_blob(update, 2, [imgData bytes], [imgData length], NULL);
14                      if( sqlite3_step(update) == SQLITE_DONE)
15                      {
16                            NSLog(@”已经写入数据”);
17                      }
18                      sqlite3_finalize(update);
19              }
20       }

你可能感兴趣的:(数据库,图片存)