when selecting "both" user warning: The used SELECT statements ... on line 498

jannalexx - May 8, 2009 - 02:54
Project:Content Management Filter
Version:6.x-1.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

user warning: The used SELECT statements have a different number of columns query: SELECT COUNT(*) FROM drupal_node n INNER JOIN drupal_users u ON n.uid = u.uid AND u.uid = 1 UNION SELECT c.cid, c.nid, c.subject AS title, c.comment, n.type, u.name AS username, u.uid, c.status, c.timestamp AS created, 0 AS changed FROM drupal_comments c INNER JOIN drupal_node n ON c.nid = n.nid INNER JOIN drupal_users u ON u.uid = c.uid AND u.uid = 1

in return pager_query

line: isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, NULL, $args);

#1

jannalexx - May 24, 2009 - 22:50
Title:error when selecting "both"» when selecting "both" user warning: The used SELECT statements ... on line 498

results are ok but:

user warning: The used SELECT statements have a different number of columns query: SELECT COUNT(*) FROM drupal_node n INNER JOIN drupal_users u ON n.uid = u.uid AND u.uid = 1 UNION SELECT c.cid, c.nid, c.subject AS title, c.comment, n.type, u.name AS username, u.uid, c.status, c.timestamp AS created, 0 AS changed FROM drupal_comments c INNER JOIN drupal_node n ON c.nid = n.nid INNER JOIN drupal_users u ON u.uid = c.uid AND u.uid = 1 in /.../sites/all/modules/cmf/cmf.module on line 498.

#2

NancyDru - July 13, 2009 - 16:33

You are going to have to provide a count query. This seems to do the trick:

      $count_query = 'SELECT COUNT(*) FROM {node} n'
        .' INNER JOIN {users} u ON n.uid = u.uid '
        . $filter['join']
        . $filter['where']
        .' UNION SELECT COUNT(*) FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid '
        .' INNER JOIN {users} u ON u.uid = c.uid '
        . $filter['join']
        . $filter['where'];

And, of course, the pager_query needs to specify this.

#3

NancyDru - July 13, 2009 - 16:33
Status:active» needs review

#4

NancyDru - July 15, 2009 - 14:20

#5

NancyDru - July 15, 2009 - 18:43
Status:needs review» fixed

Committed to both -dev versions.

#6

NancyDru - July 20, 2009 - 14:10
Status:fixed» closed

Included in new release.

 
 

Drupal is a registered trademark of Dries Buytaert.