Comment 11 for bug 288919

Revision history for this message
Pierre (pnissels) wrote :

SQL error in pp.admin.inc when prefixes are used.

Prefixes are needed on shared hosting, because the number of databases is restricted.
Drupal parses sql requests and adds the current prefix when needed, but Drupal needs to know when this needs to be done: every time a table name is written within brackets. A table name should therefore never be used "as is", like "node", but always between brackets, like "{node}".

Line 80 reads
    $result = db_query("SELECT COUNT(*) FROM {node} LEFT JOIN {content_type_story} ON node.vid = content_type_story.vid WHERE node.type = 'story' AND content_type_story.field_extended_status_value = '%s'", $value);

it should read instead
    $result = db_query("SELECT COUNT(*) FROM {node} LEFT JOIN {content_type_story} ON {node}.vid = {content_type_story}.vid WHERE {node}.type = 'story' AND {content_type_story}.field_extended_status_value = '%s'", $value);

Line 90 reads
  $result = db_query("SELECT COUNT(*) FROM {node} WHERE node.type = 'story'");

it should read instead
  $result = db_query("SELECT COUNT(*) FROM {node} WHERE {node}.type = 'story'");

I have done the changes on my installation, and it does work fine. If the correction could be delivered in a future patch, this would be great. I guess there are more places to look at.