Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:21:45+00:00 2026-06-17T19:21:45+00:00

The follow is my db function: +(NSArray*)searchWithKey:(NSString*)_key{ NSMutableArray* tmpArray = [NSMutableArray array]; static Statement*

  • 0

The follow is my db function:

+(NSArray*)searchWithKey:(NSString*)_key{
NSMutableArray* tmpArray = [NSMutableArray array];
static Statement* stmt = nil;
char* sql = "select * from Bookmarks where BMUrl like '%?%'";
if (stmt == nil) {
    stmt = [DBConnection statementWithQuery:sql];
    [stmt retain];
}
[stmt bindString:_key forIndex:1];
while ([stmt step] == SQLITE_ROW) {
    BookMark* tmpBM = [[BookMark alloc] initWithStatement:stmt];
    NSLog(@"tmpBM = %@",tmpBM);
    [tmpArray addObject:tmpBM];
    [tmpBM release];
}
[stmt reset];
return tmpArray;}

The keyword of sql is “like” which I use.But there are no results that the sqlite return.Anyone could tell me why?
I change the sql into “select * from Bookmarks where BMUrl like ‘%h%'”,there are some results which are returned.So , I guess the mistake is the function “bindString:forIndex”,the code is

- (void)bindString:(NSString*)value forIndex:(int)index{
sqlite3_bind_text(stmt, index, [value UTF8String], -1, SQLITE_TRANSIENT);}

which is the correct sqlite3 api that i will use? thank u!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:21:46+00:00Added an answer on June 17, 2026 at 7:21 pm

    Bindings aren’t interpolated like that. If you put a quotation mark in a string, as in '%?%', it will be interpreted as a literal question mark.

    You should instead modify your input _key:

    • Escape any instances of % and _ with a \
    • Add %s at the beginning and end

    This prepares it to be used with a LIKE operator.

    You also need to modify your SQL so that the ? represents a standalone parameter: ... where BMUrl like ?.


    Here’s an example for how to escape special characters and add %s at the beginning and end of _key:

    NSString *escapedKey = [_key stringByReplacingOccurencesOfString:@"%" 
                                                          withString:@"\\%"];
    escapedKey = [escapedKey stringByReplacingOccurencesOfString:@"_"
                                                      withString:@"\\_"];
    NSString *keyForLike = [NSString stringWithFormat:@"%%%@%%", escapedKey];
    [stmt bindString:keyForLike forIndex:1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the follow SQL statement: const char* sqlStatement = SELECT ((? - deal.latitude)
the follow function is not working public function matchingService() { $stmt = mysqli_prepare($this->connection, INSERT
In my model I have the follow query: function myquerydata() { $data = array();
Ok, in my code I have for example, this: $('.follow').click(function(){ var myself = $(this);
my curl function cannot follow the redirection of Facebook external link redirector, l.php and
I have a function to follow the object after the mouse, and I want
I created a javascript class as follow: var MyClass = (function() { function myprivate(param)
I cannot follow crossval() & cvpartition() function given in MATLAB documentation crossval() . What
I have this follow code in my javascript. I call this function when the
I have a JQuery validation files that look as follow: $('#TextBoxRisultati2b').on('blur', function () {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.