Count
Provides count helpers for queries that need a subquery wrapper.
This is useful when the original find definition contains joins, grouping, or other clauses where a direct model count would not represent the number of result rows correctly. The helper relies on the default PhalconKit DI because it is a static model API.
- Full name:
\PhalconKit\Mvc\Model\Traits\Count
Methods
subCount
Count rows through a subquery generated by the models manager.
public static subCount(mixed $find): int
The supplied find definition is converted to a query builder for the calling model class, compiled to SQL, and wrapped in SELECT COUNT(*) FROM (...). Bind parameters and bind types are reused from the generated query.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$find | mixed | Phalcon find parameters accepted by the models manager |
| builder. Non-array values are wrapped as a single-item parameter | ||
| array for compatibility with model find APIs. |
Return Value:
Total row count reported by the database.
Throws:
When the default DI, models manager, or database service cannot be resolved through the PhalconKit DI contract. - ServiceException