public function listUsersWithRole(Site $site, $role = null, $limit = 100, $offset = 0)
    {
        $q = $this
            ->db
            ->select('ucms_site_access', 'sa')
            ->fields('sa')
            ->fields('u', ['name', 'mail', 'status'])
            ->condition('sa.site_id', $site->id)
        ;

        // @todo
        //  - should we add an added date in the access table?
        //  - return a cursor instead ? with a count() method for paging

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

        $q->join('users', 'u', "u.uid = sa.uid");

        /* @var $q \SelectQuery */
        $r = $q
            ->range($offset, $limit)
            ->orderBy('sa.uid')
            ->execute()
        ;

        /* @var $r \PDOStatement */
        $r->setFetchMode(\PDO::FETCH_CLASS, SiteAccessRecord::class);

        return $r->fetchAll();
    }
public function listUsersWithRole(Site $site, $role = null, $limit = 100, $offset = 0)
    {
        $q = $this
            ->db
            ->select('ucms_site_access', 'sa')
            ->fields('sa')
            ->fields('u', ['name', 'mail', 'status'])
            ->condition('sa.site_id', $site->id)
        ;

        // @todo
        //  - should we add an added date in the access table?
        //  - return a cursor instead ? with a count() method for paging

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

        $q->join('users', 'u', "u.uid = sa.uid");

        /* @var $q \SelectQuery */
        $r = $q
            ->range($offset, $limit)
            ->orderBy('sa.uid')
            ->execute()
        ;

        /* @var $r \PDOStatement */
        $r->setFetchMode(\PDO::FETCH_CLASS, SiteAccessRecord::class);

        return $r->fetchAll();
    }
public function listUsersWithRole ( Site $ site , $ role = null , $ limit = 100 , $ offset = 0 ) { $ q = $ this -> db -> select ( 'ucms_site_access' , 'sa' ) -> fields ( 'sa' ) -> fields ( 'u' , [ 'name' , 'mail' , 'status' ] ) -> condition ( 'sa.site_id' , $ site -> id ) ; // @todo //  - should we add an added date in the access table? //  - return a cursor instead ? with a count() method for paging if ( $ role ) { $ q -> condition ( 'sa.role' , $ role ) ; } $ q -> join ( 'users' , 'u' , "u.uid = sa.uid" ) ; /* @var $q \SelectQuery */ $ r = $ q -> range ( $ offset , $ limit ) -> orderBy ( 'sa.uid' ) -> execute ( ) ; /* @var $r \PDOStatement */ $ r -> setFetchMode ( \ PDO :: FETCH_CLASS , SiteAccessRecord :: class ) ; return $ r -> fetchAll ( ) ; }
List users with role

If role is null, list all users

@param Site $site
@param int $role
@param int $limit
@param int $offset

@return SiteAccessRecord[]
List users with role