public function countUsersWithRole(Site $site, $role = null)
    {
        /* @var $q \SelectQuery */
        $q = $this->db
            ->select('ucms_site_access', 'u')
            ->condition('u.site_id', $site->id);

        if ($role) {
            $q->condition('u.role', $role);
        }

        $q->addExpression('COUNT(*)');

        /* @var $r \PDOStatement */
        $r = $q->execute();

        return $r->fetchField();
    }
public function countUsersWithRole(Site $site, $role = null)
    {
        /* @var $q \SelectQuery */
        $q = $this->db
            ->select('ucms_site_access', 'u')
            ->condition('u.site_id', $site->id);

        if ($role) {
            $q->condition('u.role', $role);
        }

        $q->addExpression('COUNT(*)');

        /* @var $r \PDOStatement */
        $r = $q->execute();

        return $r->fetchField();
    }
public function countUsersWithRole ( Site $ site , $ role = null ) { /* @var $q \SelectQuery */ $ q = $ this -> db -> select ( 'ucms_site_access' , 'u' ) -> condition ( 'u.site_id' , $ site -> id ) ; if ( $ role ) { $ q -> condition ( 'u.role' , $ role ) ; } $ q -> addExpression ( 'COUNT(*)' ) ; /* @var $r \PDOStatement */ $ r = $ q -> execute ( ) ; return $ r -> fetchField ( ) ; }
Count users having a specific role.
If role is null, count all users.

@param Site $site
@param int $role

@return int
Count users having a specific role . If role is null count all users .