I am doing the next inside a custom function:
$exists = $wpdb->query($wpdb->prepare(' SELECT COUNT(*) FROM wp_%d_gdsr_data_article WHERE post_id = %d ', $blog_id, $post_id));
$is available examines to at least one even when no rows are came back through the query. Also, var_dump($wpdb->queries) yields a NULL. Anybody know what's going on here?
$wpdb->get_row() to retrieve just one row like a single object (or array), and
$wpdb->get_results() to obtain a result set.
In the documentation:
The function returns an integer akin to the amount of rows affected/selected. If there's a MySQL error, the function will return FALSE. (Note: since both and FALSE could be came back, make certain you apply the correct comparison operator: equality == versus. identicality ===).
The query returns 1 row therefore the
query() function returns
1 - and can always return
1 for that query that you simply publish inside your question, even when the amount of rows selected through the
COUNT is . Use
get_results as recommended by TheDeadMedic to obtain the actual consequence of the query, which can be