Yeah this part is confusing: the count()
method actually executes a SELECT COUNT(*)
statement. It takes the same arguments as the load()
method, so in your case :
$group_qry->count(array('type=?',$name));
It is not exactly what you need, since it will execute a second SELECT
, which will reduce performance.
What you need is to count the number of rows in the result array. Since this array is a protected variable, you'll need to create a dedicated function for that in the UserGroup
class:
class UserGroup extends \DB\SQL\Mapper {
function countResults() {
return count($this->query);
}
}
If you feel that it's a bit of overkill for such a simple need, you can file a request to ask for the framework to handle it. Sounds like a reasonable demand.
UPDATE:
It's now part of the framework. So calling $group_qry->loaded()
will return the number of loaded records.