I have a check I'm trying to run for whether the number of rows in a table is less than N+8. The reason it's very messy is because I have to use the WordPress API and get_results
function ( https://developer.wordpress.org/reference/classes/wpdb/get_results/ ) to get everything from MySQL land to PHP land.
What I have is
$stillSomeLeft = ($wpdb->get_results($wpdb->prepare("SELECT COUNT(*) FROM $thisTable < (%d + 8)", $_POST['numItemsLoaded']))) === true;
and $stillSomeLeft
is always evaluating to false
. Of course, since get_results
returns an object corresponding to the result of the query, I have no way of knowing exactly what that object will be, but since the query would return true
/ false
in MySQL land, I assume the PHP equivalent "object" will be the same.
Gotta love loosely-typed languages ...
Your problem is the select statement
You only need
SELECT COUNT(*) FROM $thisTable
With that value you compare to N + 8 in your PHP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.