[wp-hackers] $wpdb->get_var unable to return negative numbers...

Dion Hulse (dd32) wordpress at dd32.id.au
Thu Nov 21 13:20:39 UTC 2013


get_var() can return negitive numbers.

For example:
var_dump( $wpdb->get_var( "SELECT -1 as minus" ) );

or if wanted as an integer rather than a string:
var_dump( (int)$wpdb->get_var( "SELECT -1 as minus" ) );

The SQL query can be returning a field from a database of course, this is
just for simulating the response from MySQL of a negative number.



On 21 November 2013 21:33, BenderisGreat <greglancaster71 at gmail.com> wrote:

> Is there anyway to return negative values when using get_var?  If not, what
> is a good alternative?
>
>
>
> --
> View this message in context:
> http://wordpress-hackers.1065353.n5.nabble.com/wpdb-get-var-unable-to-return-negative-numbers-tp42895.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list