title: fmdb - select query with like to avoid sql injection
body: <p>Hello guys and merry Christmas to all of you!</p>
  
  <p>I am building an iOS app using sqlite and fmdb as wrapper.
  I am trying to execute the following sql statement:</p>
  
  <pre><code>SELECT * FROM TABLE WHERE FIELD LIKE '%text%'
  </code></pre>
  
  <p>with the text coming from a UISearchBar.</p>
  
  <p>Up to now the only way i got it working was with the following code:</p>
  
  <pre><code>NSString *query = [NSString stringWithFormat:@"SELECT * FROM TABLE WHERE FIELD LIKE '%%%@%%'", text];
  FMResultSet *results = [db executeQuery:query];
  </code></pre>
  
  <p>Please note i am posting only the query code. It works well.</p>
  
  <p>What I want though, is to avoid sql injection so I am trying something like:</p>
  
  <pre><code>NSString *query = @"SELECT * FROM TABLE WHERE FIELD LIKE %%?%%";
  FMResultSet *results = [db executeQuery:query, text];
  </code></pre>
  
  <p>or something like:</p>
  
  <pre><code>NSString *query = @"SELECT * FROM TABLE WHERE FIELD LIKE ?";
  FMResultSet *results = [db executeQuery:query, [NSString stringWithFormat:@"%%%@%%", text]];
  </code></pre>
  
  <p>that do not work. The same happens with single quotes around the like clause ('%%?%%') or single % instead of double.</p>
  
  <p>Can you walk me through this issue?
  Any help would be much appreciated!</p>
  
  <p>Happy New Year!</p>