I'm trying to update a module (my first time trying something on the code level of PHP). I think I have almost everything working (after searching other posts, etc.). The exception is found in the following lines of the site_map module:
$result = db_query('SELECT DISTINCT t.tid, n.nid FROM {term_node} t '. _node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. _node_access_where_sql());
$result = db_query("SELECT DISTINCT t.tid, n.nid FROM {term_node} t, {node} n ". _node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". _node_access_where_sql(), $type);
I have replaced the "node" with the "_node" and tried adding in a "db_rewrite_sql()" statement to each of these lines according to the patch discussion I found at http://drupal.org/node/17666. My knowledge of PHP syntax (or anything PHP, for that matter) has prevented me from success. My attempted patch is:
$result = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), t.tid FROM {term_node} t '. _node_access_join_sql() .'INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND '. _node_access_where_sql()));
$result = db_query(db_rewrite_sql('SELECT DISTINCT(n.nid), t.tid FROM {term_node} t, {node} n ". _node_access_join_sql() ." WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' AND ". _node_access_where_sql(), $type));
This returns an error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING. Can anyone give me a quick lesson in what I'm doing wrong with this code? Thanks in advance for any help, and understanding that I'm just getting my feet wet with this stuff.
Comments
node/12347
it's http://drupal.org/node/12347
I'd try this. That FROM table1, table2 WHERE constraint should be rewritten into a join which I have not done.
--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.
That's the ticket!
The module, site_map, seems to work perfectly now! Thank you for the help. I'll post these changes to the site_map project page.