Similar entries: parameters to query in function theme_similar_content unused

schildi - May 19, 2008 - 12:27
Project:Similar Entries
Version:5.x-2.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:by design
Description

there are several parameters applied to the queries in function theme_similar_content.
The last two of them seem to be unused / ignored .
Is the query incomplete?

db_query_range("SELECT r.nid, MATCH(r.body, r.title) AGAINST ('%s') AS score FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid AND r.vid = n.vid INNER JOIN {term_node} t ON n.nid = t.nid AND t.tid IN ($taxonomy_tids) WHERE MATCH(r.body, r.title) AGAINST ('%s') AND n.status <> 0 AND r.nid <> %d AND n.type IN ($types) GROUP BY n.nid ORDER BY score DESC, r.vid DESC", $text, $text, $node->nid, 0, variable_get('similar_num_display', 5));

#1

deekayen - May 19, 2008 - 13:21
Category:bug report» support request
Status:active» by design

db_query_range is a special wrapper to queries. The last two parameters are used to insert a LIMIT clause on the end of the statement. The theory is that it makes the query more compatible across DB types (MySQL vs PostgreSQL). In this case, 0 says to start from the top and similar_num_display is the setting defaulting to 5 to pull only five matches from the DB then stop searching.

#2

schildi - May 19, 2008 - 20:09

yes, of course. I know the function of the LIMIT clause but didn't realize that the parameters were applied to the db_query_range.
Sorry for that!

 
 

Drupal is a registered trademark of Dries Buytaert.