![php](https://habrastorage.org/r/w120/files/373/e8b/dd3/373e8bdd3cb644d3bbeba47d34d1876d.png)
PHP
2
Вклад в тег
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
namespace app\components;
use yii\rbac\DbManager;
class MyDBManager extends DbManager
{
/**
* Возвращает количество пользователей определенной роли
*
* @param string $role название роли
* @return integer кол-во юзеров определенной роли
*/
public function getUserCountByRole($role){
return (new \yii\db\Query())
->select('user_id')
->from('tbl_auth_assignment')
->where('item_name = :role', [':role' => $role])
->count();
}
}
use app\components\MyDBManager;
...
public function actionIndex()
{
$auth = new MyDbManager();
echo $auth->getUserCountByRole("admin");
}