Fatal error: Call to undefined function db_rewrite_sql() in /var/www/drupal-7/sites/all/modules/hierarchical_select/modules/hs_taxonomy.module on line 730

I am facing this issue when i enabled hierarchical select for taxonomy then I got this fatal error I think db_rewrite_sql() function is not present in drupal 7 and we are still using this function.
Please resolve this issue.

Comments

manau2000’s picture

The same problem. Anyone have a solution?? please

DanW’s picture

I also have this problem.

a.siebel’s picture

subscribe

andy.s.clark’s picture

Also seeing this issue.

dimapv’s picture

I have the same problem. When I try to get access to some admin sides page, I have the blank screen and the error record in apache' log. I restored functionality via DB change with phpmyadmin. In the 'variable' table I clear value in the record name='hs_config_taxonomy-2' and clear all caches twice.

Before manipulation, make the full DB backup!!!

mitzai’s picture

Same issue here. I'm working on a xampp Local install

khanjeee’s picture

Title: Fatal error: Call to undefined function db_rewrite_sql() in /var/www/drupal-7/sites/all/modules/hierarchical_select/modules/hs_t » same issue dont any 1 heregot the solution :(

same issue dont any 1 heregot the solution :(

krisgraham’s picture

The undefined function db_rewrite_sql no longer exists in D7.

This query basically counts the nodes for each term... so you should be able to comment out the lines calling on it in hs_taxonomy.module. You also need to comment out the return $count... a couple lines down. Here's the relevant code segment with the right parts commented out.

  if (!isset($count[$type][$tid])) {
    if (is_numeric($type)) {
      // TODO Please convert this statement to the D7 database API syntax.
	  
      //$count[$type][$tid] = db_query(db_rewrite_sql("SELECT COUNT(DISTINCT(n.nid)) AS count FROM {taxonomy_term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND t.tid IN (%s)"), implode(',', $tids))->fetchField();
    }
    else {
      // TODO Please convert this statement to the D7 database API syntax.
      //$count[$type][$tid] = db_query(db_rewrite_sql("SELECT COUNT(DISTINCT(n.nid)) AS count FROM {taxonomy_term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND n.type = '%s' AND t.tid IN (%s)"), $type, implode(',', $tids))->fetchField();
    }
  }
  //return $count[$type][$tid];
}

This is just a quick fix so use at your discretion.

As you can see, the comments state that this section needs to be updated to use the D7 query syntax, so if anyone is familiar with that, it shouldn't be too difficult to replicate. New DB query API: http://drupal.org/developing/api/database

wim leers’s picture

Status: Active » Closed (duplicate)