[wp-trac] Re: [WordPress Trac] #4065: useful function: merge_wp_queries()

WordPress Trac wp-trac at lists.automattic.com
Sun May 10 15:17:48 GMT 2009


#4065: useful function: merge_wp_queries()
----------------------------+-----------------------------------------------
 Reporter:  markjaquith     |       Owner:  anonymous  
     Type:  task (blessed)  |      Status:  new        
 Priority:  low             |   Milestone:  2.9        
Component:  Optimization    |     Version:             
 Severity:  normal          |    Keywords:  needs-patch
----------------------------+-----------------------------------------------

Comment(by Denis-de-Bernardy):

 A better approach, imo, would be to change this:

 {{{
 function WP_Query ($query = '') {
         if (! empty($query)) {
                 $this->query($query);
         }
 }
 }}}

 into something like:

 {{{
 function WP_Query ($query = '') {
         $args = func_get_args();
         if (! empty($query) && count($args) == 1) {
                 $this->query($query);
         } elseif ( count($args) > 1 ) {
                 $this->union_query($query);
         }
 }
 }}}

 that way, there is no need to actually merge the stuff in php. we'd union
 query the entire thing in one go. it requires subqueries, however, since
 the order by would need to apply to the fully unioned query passed as a
 subselect.

 also, there are chances it would be *slow* (whichever way is used).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/4065#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list