getTotalCount()
Returns the total number of rows that would have been returned by the last get() query, if no LIMIT was used. Requires prior use of withTotalCount().
Signature:
public function getTotalCount(): int
Example
// Enable total count tracking
$db->setPageLimit(20);
$db->withTotalCount();
$orders = $db->get('test_orders');
// Actual results on this page
echo "Showing " . count($orders) . " of " . $db->getTotalCount() . " total orders.";
Important:
getTotalCount() only works if withTotalCount() was called before the last query. Otherwise, the return value will be 0.
Deprecated: The property
$db->totalCount is deprecated and has been removed as of v1.5.x.
Use Instead: Call
getTotalCount() after executing a paginated get() query with withTotalCount() enabled. This method is instance-safe and compatible with parallel database connections.