I have this:
global $wpdb; $wpdbp = $wpdb->prepare('SELECT EXISTS ([some query] WHERE user_id =%d);',$target_user_id); $result = $wpdb->get_results($wpdbp);
I want to know if the query result is 1 or 0. But a var_dump() of $result give something like:
array (size=1) 0 => object(stdClass) public 'EXISTS ([some query] WHERE user_id =2)' => string '0' (length=1)
Which means I should first get element 0 of array, but then, I need to access a property which name is literally the whole query.
I yet need to test if that is even doable in php (I guess yes but I don't remember in this language precisely), and what happens if I have multiline query ... Anyway I find that so ugly ... is there a cleaned way to get query result? Maybe there's a way to give a name string to the query or so?
Here is what I'm trying and this isn't even working ...
$qeryAsPropertyName = substr($wpdbp,7, -strlen($wpdbp-1)); $result0 = $result->$qeryAsPropertyName;