// $Id: nodequeue.module,v 1.37 2006/08/10 21:41:26 killes Exp $

nodequeue_page_form()

The first query of this function gives wrong COUNT results in 'numrows'.

The query should be something like this instead:

SELECT 
  nq.qid, nq.title, nq.size, COUNT(DISTINCT(nqn.nid)) AS numnodes
FROM 
  nodequeue_queue nq 
  LEFT JOIN nodequeue_types nt ON (nq.qid = nt.qid)
  LEFT JOIN nodequeue_roles nr ON (nq.qid = nr.qid)
  LEFT JOIN nodequeue_nodes nqn ON (nq.qid = nqn.qid)
WHERE 
  nt.type = '%s' AND nr.rid IN (". implode(',', $role_args) .")
GROUP BY
  nq.qid
ORDER BY
  nq.title

No need to use INNER JOIN or another GROUP BY.
At the moment, your query returns multiple rows and always 1 in numrows.

Comments

merlinofchaos’s picture

Fixed. The INNER joins are left in; they are more efficient than LEFT joins and provide faster queries as long as you know that there will always be records to join with. Which in this case there will be.

This will go out in the 1.1 release for 4.7

merlinofchaos’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)