I currently have this code:
$result = $db->prepare("SELECT * FROM `users` WHERE MATCH (`name`, `blurb`) AGAINST (:quer IN BOOLEAN MODE) LIMIT $rpage, $max_show;"); $result->execute(array(":quer" => $query)); $count = $db->prepare("SELECT COUNT(*) FROM `users` WHERE MATCH (`name`, `blurb`) AGAINST (:quer IN BOOLEAN MODE);"); $count->execute(array(":quer" => $query));
The first query captures a bunch of rows from the table. The second counts lines that match the same criteria as the first, which allows pagination.
Is it possible to combine these two queries into one? And will it be more effective?
source share