[development] problem with db_rewrite_sql
Lluís
enboig at gmail.com
Tue Nov 24 09:03:07 UTC 2009
I am using group by module, and db_rewrite_sql is giving me problems
because it cause rows to be selected twice and SUM reports double
their value.
After doing some research I have found that if I change:
function node_db_rewrite_sql($query, $primary_table, $primary_field) {
if ($primary_field == 'nid' && !node_access_view_all_nodes()) {
$return['join'] = _node_access_join_sql($primary_table);
$return['where'] = _node_access_where_sql();
$return['distinct'] = 1;
return $return;
}
}
to:
function node_db_rewrite_sql($query, $primary_table, $primary_field) {
if ($primary_field == 'nid' && !node_access_view_all_nodes()) {
if (($where=_node_access_where_sql('view','new_na'))!='') {
$return['where'] = "".$primary_table.".".$primary_field." IN
(SELECT new_na.nid FROM {node_access} new_na WHERE ".$where.")";
return $return;
}
}
}
everything works as expected.
Is there any reason why using "INNER JOIN" is better than using "
WHERE nid IN (SELECT ... FROM {node_access} ... )"?
--
*Les normes hi són perquè hi pensis abans de saltar-te-les
*La vida és com una taronja, què esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.
More information about the development
mailing list