Exemplo n.º 1
0
 /**
  * Get all users
  *
  * @return array
  */
 public function getAllUsers()
 {
     return Table\Users::findAll()->rows();
 }
Exemplo n.º 2
0
 /**
  * Get count of users
  *
  * @param  int    $roleId
  * @param  string $username
  * @param  array  $deniedRoles
  * @return int
  */
 public function getCount($roleId = null, $username = null, array $deniedRoles = [])
 {
     $params = [];
     $sql = Table\Users::sql();
     $sql->select();
     if (null !== $username) {
         $sql->select()->where('username LIKE :username');
         $params['username'] = $username . '%';
     }
     if (null !== $roleId) {
         $sql->select()->where('role_id = :role_id');
         $params['role_id'] = $roleId;
     }
     if (count($deniedRoles) > 0) {
         foreach ($deniedRoles as $key => $denied) {
             $sql->select()->where('role_id != :role_id' . ($key + 1));
             $params['role_id' . ($key + 1)] = $denied;
         }
     }
     if (count($params) > 0) {
         return Table\Users::execute((string) $sql, $params, Table\Users::ROW_AS_ARRAY)->count();
     } else {
         return Table\Users::findAll(null, Table\Users::ROW_AS_ARRAY)->count();
     }
 }