if ((!obj) || ((NSNull *)obj == [NSNull null])) {

sqlite3_bind_null(pStmt, idx);

}

// FIXME - someday check the return codes on these binds.

else if ([obj isKindOfClass:[NSData class]]) {

const void *bytes = [obj bytes];

if (!bytes) {

// it's an empty NSData object, aka [NSData data].

// Don't pass a NULL pointer, or sqlite will bind a SQL null instead of a blob.

bytes = "";

}

sqlite3_bind_blob(pStmt, idx, bytes, (int)[obj length], SQLITE_STATIC);

}

else if ([obj isKindOfClass:[NSDate class]]) {

if (self.hasDateFormatter)

sqlite3_bind_text(pStmt, idx, [[self stringFromDate:obj] UTF8String], -1, SQLITE_STATIC);

else

sqlite3_bind_double(pStmt, idx, [obj timeIntervalSince1970]);

}

else if ([obj isKindOfClass:[NSNumber class]]) {

if (strcmp([obj objCType], @encode(BOOL)) == 0) {

sqlite3_bind_int(pStmt, idx, ([obj boolValue] ? 1 : 0));

}

else if (strcmp([obj objCType], @encode(int)) == 0) {

sqlite3_bind_int64(pStmt, idx, [obj longValue]);

}

else if (strcmp([obj objCType], @encode(long)) == 0) {

sqlite3_bind_int64(pStmt, idx, [obj longValue]);

}

else if (strcmp([obj objCType], @encode(long long)) == 0) {

sqlite3_bind_int64(pStmt, idx, [obj longLongValue]);

}

else if (strcmp([obj objCType], @encode(unsigned long long)) == 0) {

sqlite3_bind_int64(pStmt, idx, (longlong)[obj unsignedLongLongValue]);

}

else if (strcmp([obj objCType], @encode(float)) == 0) {

sqlite3_bind_double(pStmt, idx, [obj floatValue]);

}

else if (strcmp([obj objCType], @encode(double)) == 0) {

sqlite3_bind_double(pStmt, idx, [obj doubleValue]);

}

else {

sqlite3_bind_text(pStmt, idx, [[obj description] UTF8String], -1, SQLITE_STATIC);

}

}

else {

sqlite3_bind_text(pStmt, idx, [[obj description] UTF8String], -1, SQLITE_STATIC);

}

最新文章

  1. angular之上滑换页指令
  2. 洛谷P1373 小a和uim之大逃离[背包DP]
  3. [uwsgi] no request plugin is loaded, you will not be able to manage requests.
  4. 409. Longest Palindrome
  5. php实现图片缩放功能类
  6. window.open参数设置及如何全屏显示(转)
  7. vb6如何将MSHFlexGrid控件中的内容导出为Excel
  8. SQL server 开启 cmdshell
  9. UIScrollView控件详解
  10. iOS7以后的侧滑返回上一页
  11. 人工智能之基于face_recognition的人脸检测与识别
  12. sql server登录名、服务器角色、数据库用户、数据库角色、架构区别联系
  13. maven相关配置
  14. JavaScript:document.execCommand()的用法
  15. 用Handler的post()方法来传递线程中的代码段到主线程中执行
  16. Sorted sets
  17. [转]Ubuntu默认root用户密码
  18. JDK的安装与卸载
  19. ifconfig与内核通信 ifreq 结构体分析和使用
  20. Workflow:采用坐标变换(移动和旋转)画箭头

热门文章

  1. C++求平均数
  2. Java打印温度转换表
  3. slidingmenu
  4. mysql开启全文索引功能
  5. pandas聚合和分组运算——GroupBy技术(1)
  6. 第二十章 数据访问(In .net4.5) 之 使用LINQ
  7. springMVC+jpa配置之简单案例
  8. Microsoft Azure 的一些限制 Global
  9. SQL基础篇——如何搭建一个数据库
  10. Ajax-goahead局部刷新页面