Question

I find it very inconvenient and hard to understand that the default behavior of the Wordpress db-interface is to convert all integer (and float?) types to strings.

e.g

$wp_posts = $wpdb->get_results('SELECT * from wp_posts');
$unexpected_type = gettype($wp_posts[0]->ID)  == 'string';

Please confirm my suspicion that this is done in order to support very large (capacious) integer types that are not supported by PHP, or provide an alternative explanation as to why one would chose to convert integers to strings.

The second part of my question, as maybe expected, is to find out if there is a built in configuration parameter to the wpdb class that would allow one to request integers for integer-type records.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top