[wp-trac] Re: [WordPress Trac] #4090: $wpdb->get_var("SELECT 1 FROM ... ") not working

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 6 02:03:04 GMT 2007


#4090: $wpdb->get_var("SELECT 1 FROM ... ") not working
--------------------------+-------------------------------------------------
 Reporter:  orvar         |        Owner:  anonymous
     Type:  defect        |       Status:  new      
 Priority:  normal        |    Milestone:  2.3      
Component:  General       |      Version:  2.1.2    
 Severity:  normal        |   Resolution:           
 Keywords:  get_var wpdb  |  
--------------------------+-------------------------------------------------
Comment (by orvar):

 This problem stem from `mysql_fetch_object` which is being used in
 `wpdb->query`. Selecting any numerical value, even if its in quotes,
 results in an empty object (eg. "SELECT 1000,'123',2007 FROM ...").

 Maybe the [http://codex.wordpress.org/Function_Reference/wpdb_Class Codex]
 should just reflect that `get_var("SELECT 1 FROM ...")` does not work (its
 a fairly common practice) -- while alternatives like `get_var("SELECT 1=1
 FROM ...")` and `get_var("SELECT TRUE FROM ...")` for some reason do work
 (TRUE is an alias for 1 in mysql).

 This could though be fixed with a query filter in the core -- but is it
 worth it?

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4090#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list