[wp-trac] [WordPress Trac] #5108: More wrapper functions for direct queries

WordPress Trac wp-trac at lists.automattic.com
Sun Sep 30 02:30:08 GMT 2007


#5108: More wrapper functions for direct queries
--------------------------+-------------------------------------------------
 Reporter:  Viper007Bond  |       Owner:  anonymous  
     Type:  enhancement   |      Status:  new        
 Priority:  normal        |   Milestone:  2.4        
Component:  General       |     Version:  2.3        
 Severity:  normal        |    Keywords:  needs-patch
--------------------------+-------------------------------------------------
 I need to get the number of comments awaiting moderation. Apparently the
 only way to do this is a direct SQL query:

 {{{
 $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE
 comment_approved = '0'" );
 }}}

 The problem with this is forwards compatibility (what if the structure of
 the table is changed?) as well as more complex code.

 I propose common queries such as approved comments, spam comments,
 comments in moderation, all comments, etc. be wrapped into functions that
 return the data. That way the function can be updated with no ill effects
 or changes to the code.

 This could be applied to post queries as well.

 Simply put, the less direct querying, the better IMO.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5108>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list