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()
?
-
Why not use that array and get the string from it?– keroCommented Nov 13, 2018 at 17:32
-
I converted it to JSON but still don't know how to access the string in the loop. I have an array of json objects here. Any hints?– LimpulsCommented Nov 13, 2018 at 17:55
Add a comment
|
1 Answer
$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