Discussion:
$wpdb->get_var unable to return negative numbers...
BenderisGreat
2013-11-21 11:33:17 UTC
Permalink
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.
Dion Hulse (dd32)
2013-11-21 13:20:39 UTC
Permalink
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.
Post by BenderisGreat
Is there anyway to return negative values when using get_var? If not, what
is a good alternative?
--
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
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...