}
}
- $subsql[] = $dbr->selectSQLText(
+ if( $dbr->unionSupportsOrderAndLimit())
+ $order = array( 'ORDER BY' => 'rc_timestamp DESC' );
+ else
+ $order = array();
+
+
+ $query = $dbr->selectSQLText(
array_merge( $tables, array( $link_table ) ),
$select,
$conds + $subconds,
__METHOD__,
- array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options,
+ $order + $query_options,
$join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) )
);
+
+ if( $dbr->unionSupportsOrderAndLimit())
+ $query = $dbr->limitResult( $query, $limit );
+
+ $subsql[] = $query;
}
if( count($subsql) == 0 )
return false; // should never happen
- if( count($subsql) == 1 )
+ if( count($subsql) == 1 && $dbr->unionSupportsOrderAndLimit() )
$sql = $subsql[0];
else {
// need to resort and relimit after union