Can someone please point me to the right direction.
This works fine to me in Drupal 6, but i figured out that db_rewrite_sql is not available in Drupal 7 like so:
$result = db_query_range(db_rewrite_sql("SELECT ... FROM {...} WHERE LOWER(...) LIKE LOWER('%s%%')"), $string, 0, 10);
What is the work around of this in Drupal 7 using the query tagging system?
Thanks in advance!!

Comments

jpoesen’s picture

See http://blog.worldempire.ch/comment/715
--> I think this explains everything you need, in particular:

Because we are querying the node table, we should add the node_access tag. This is the replacement of db_rewrite_sql() that is now longer needed in Drupal 7.

$query = db_select('node', 'n');
$query->addTag('node_access');

$query
  ->fields('n', array('nid', 'title', 'body')) 
  ->orderBy('n.nid', 'DESC') 
  ->condition('n.type', 'page') 
  ->range(0, 5); 

See full article for more examples.

TrainingCloud.io - Drupal Training with a Heart.

tapscola’s picture

Thank you JP for the link it worked fine and i also figured out on drupal_json and db_fetch_object work-arounds.