Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294802

UNION queries don't support PagerDefault

$
0
0

The following fails:

<?php
  $query1
= db_select('a_blog', 'cb')
          ->
fields('cb', array('title', 'changed_date'));

 
$query2 = db_select('a_gallery', 'cg')
            ->
fields('cg', array('title', 'changed_date'));
   
 
$query1->union($query2, 'UNION ALL');
 
$query1 = $query1->extend('PagerDefault');                 
 
$results = $query1->execute();
?>

The error is:

PDOException: SQLSTATE[21000]: Cardinality violation: 1222 The used SELECT statements have a different number of columns: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {a_blog} cb UNION ALL SELECT cg.title AS title, cg.changed_date AS changed_date FROM {a_gallery} cg) subquery; Array ( ) in PagerDefault->execute() (line 74 of /Users/aangelantoni/Sites/base/includes/pager.inc).

OrderBy with UNIONS doesn't work (see http://drupal.org/node/1145076) and LIMITs with UNIONS don't work, either (as of 7.15).


Viewing all articles
Browse latest Browse all 294802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>