Count Query Results
-
The following options are available to count query results:
Count
Count query results using the Count
method.
/** @var int $numberOfOrders */
$numberOfOrders = $session->advanced()
->documentQuery(Order::class)
->whereEquals("ship_to.country", "UK")
// Calling 'Count' from Raven.Client.Documents.Session
->Count();
// The query returns the NUMBER of orders shipped to UK (int)
from "Orders"
where ShipTo.Country == "UK" limit 0, 0
// The RQL generated will trigger query execution
// however, no documents are returned (limit is set 0)
Get count from query stats
When executing a query, you can retrieve the query statistics that include the total number of results.
Learn more in Get Query Statistics.