Biblioreference module keyword fetching SQL wrong turns
re[] = "n.type = 'biblio'";
$count = count($words);
for ($i = 0; $i < $count; $i++) {
$where[] = 'bk.word ' . $match_operators[$match];
// for multiple words we're going to have to string a bunch of these together with "or"
// first we took only the first word as a proof of concept
// now we're sticking with and, not or, so multiple words act as filtering
}
$args = $words;
$where_clause = $where ? 'where '. implode(' and ', $where) : '';
// right way -- actually, no need for db_rewrite_sql 'cause we aren't honoring node access-- or are we? i guess we have n.nid in there and that can be acted on
// $sql = db_rewrite_sql("select n.nid, n.title as node_title, n.type as node_type from {node} n $where_clause order by n.title, n.type");
// $result = db_query( limit %d", $limit);
// wrong in so many ways-- especially the where clause, must be or if we search
// for multiple words, but why does this work at all? in any case it does not work as intended.
// $sql = db_rewrite_sql("select count(bk.nid) as nidcount, bk.nid as nid, n.title as node_title from {biblioreference_keyword} bk left join {node} n on n.nid=bk.nid $where_clause group by bk.nid order by nidcount desc");
// this also doesn't work
// $sql = "select bk.nid as nid, n.title as node_title from biblioreference_keyword
bk left join node
n on n.nid=bk.nid where n.type = 'biblio' and bk.word like '%s%%'";
$sql = "select bk.nid as nid, n.title as node_title from {biblioreference_keyword} bk left join {node} n on n.nid=bk.nid " . $where_clause;
$limit = null;
$result = $limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args);
(Special thanks to how to get a c with cedilla on Ubuntu for making it possible for me to log in to Agaric from .)
Comments
Post new comment