So I'm using $wpdb->get_results()
to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()
?
So I'm using $wpdb->get_results()
to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()
?
$wpdb->get_results()
only returns arrays( associative or numeric) or an object. It does not return a string value.
If you want a string value, you need to use $wpdb->get_var()
instead