iphone - 在 xcode for iphone 中带有 LIKE 语句的 sqlite

标签 iphone sqlite bind

第一个(许多?)帖子在这里。

我的陈述有问题。

sqlite3_stmt *statement;
    const char *query = "select * from words where ordet LIKE ?001";

    NSString *wildcard = [NSString stringWithFormat:@"%@%%", fullWordForSQL.text];
    sqlite3_bind_text(statement, 1, [wildcard UTF8String], -1, SQLITE_STATIC);

    if (sqlite3_prepare_v2(dbHandle, query, -1, &statement, NULL) == SQLITE_OK ){
        NSLog(@"in if");
        NSLog(@"Data: %s", query);

我已通过查询成功检索数据:
const char *query = "select * from words where ordet LIKE "_test__";

但是当我尝试绑定(bind)动态创建的单词时,它不会粘住。
我的 nslog 打印“数据:从 ordet LIKE ?001 的单词中选择 *”所以不知何故我没有让绑定(bind)工作。
我知道上面的代码会出现其他问题,但现在我陷入了这个问题

最佳答案

query调用 sqlite3_bind_text() 时不会改变.如果您考虑一下,它不会改变,因为您将其声明为 const char * .你想做的是使用sqlite3_trace()注册以获取带有最终绑定(bind)字符串的回调,以便您可以查看实际发生的情况。

关于iphone - 在 xcode for iphone 中带有 LIKE 语句的 sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5542214/

相关文章:

iphone - 如何在 iOS 的 UIDatePicker 中禁用以前的时间

iphone - 如何在ios上实现360度展示案例?

android - 没有这样的列名 sqlite android

linux - Google 托管的子域的 MX 问题

c++ - Boost初学者,boost::bind噩梦

iphone - 奇怪的 iOS 内存分配行为

ios - UIView 动画使 UICollectionView 委托(delegate)变得模糊 - Swift

java - 如何在android本地数据库中存储intent?

database - 在 sqlite3 中按标题将 .csv 文件导入表中

jQuery:将 ajaxForm 绑定(bind)到通过 .load() 加载的页面上的表单