本文整理汇总了PHP中Role::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::count方法的具体用法?PHP Role::count怎么用?PHP Role::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionList
public function actionList()
{
$page = isset($_GET['id']) ? intval($_GET['id']) : 1;
$list = array();
$criteria = new CDbCriteria(array('order' => 'id ASC'));
$roles = new Role();
$count = $roles->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = Yii::app()->params['postsPerPage'];
$pager->setCurrentPage($page - 1);
$pager->applyLimit($criteria);
$list = $roles->findAll($criteria);
$this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list));
}
示例2: listRole
public function listRole()
{
if (!Request::ajax()) {
return App::abort(404);
}
$start = Input::has('start') ? (int) Input::get('start') : 0;
$length = Input::has('length') ? Input::get('length') : 10;
$search = Input::has('search') ? Input::get('search') : [];
$roles = Role::select('id', 'name');
if (!empty($search)) {
foreach ($search as $key => $value) {
if (empty($value)) {
continue;
}
$value = ltrim(rtrim($value));
$roles->where($key, 'like', '%' . $value . '%');
}
}
$order = Input::has('order') ? Input::get('order') : [];
if (!empty($order)) {
$columns = Input::has('columns') ? Input::get('columns') : [];
foreach ($order as $value) {
$column = $value['column'];
if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
continue;
}
$roles->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
}
}
$count = $roles->count();
if ($length > 0) {
$roles = $roles->skip($start)->take($length);
}
$arrRoles = $roles->get()->toArray();
$arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Role::count(), 'recordsFiltered' => $count, 'data' => []];
if (!empty($arrRoles)) {
foreach ($arrRoles as $role) {
$arrReturn['data'][] = array(++$start, $role['id'], $role['name']);
}
}
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}
示例3: roles
function roles()
{
$role = new Role();
$total_rows = $role->count();
switch ($this->input->get('c')) {
case "1":
$data['col'] = "role_name";
break;
case "2":
$data['col'] = "role_id";
break;
default:
$data['col'] = "role_id";
}
if ($this->input->get('d') == "1") {
$data['dir'] = "DESC";
} else {
$data['dir'] = "ASC";
}
$data['title'] = "Roles";
$data['btn_add'] = anchor('users/add_role', 'Add New', "class='btn btn-primary'");
$data['btn_home'] = anchor(base_url(), 'Home', "class='btn btn-home'");
$uri_segment = 3;
$offset = $this->uri->segment($uri_segment);
$role->order_by($data['col'], $data['dir']);
$data['role_list'] = $role->get($this->limit, $offset)->all;
$config['base_url'] = site_url("users/roles");
$config['total_rows'] = $total_rows;
$config['per_page'] = $this->limit;
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('users/index_roles', $data);
}
示例4: run
public function run()
{
if (Role::count() == 0) {
$this->generate();
}
}
示例5: download
public function download()
{
$name = 'Data';
$formats = array('xls', 'xlsx');
if (in_array(Input::get('format'), $formats)) {
$format = Input::get('format');
} else {
$format = 'xls';
}
$month = Input::get('startMonth');
if (!($month > 0 && $month < 13)) {
$month = 1;
}
$year = Input::get('startYear');
if (!($year >= 2014 && $year <= date('Y'))) {
$year = 2014;
}
$name .= "_{$month}-{$year}";
if ($month < 10) {
$month = '0' . $month;
}
$from = "{$year}-{$month}-01 00:00:00";
$month = Input::get('endMonth');
if (!($month > 0 && $month < 13)) {
$month = 1;
}
$year = Input::get('endYear');
if (!($year >= 2014 && $year <= date('Y'))) {
$year = 2014;
}
$name .= "_{$month}-{$year}";
$month++;
if ($month > 12) {
$month = 1;
$year++;
}
if ($month < 10) {
$month = '0' . $month;
}
$to = "{$year}-{$month}-01 00:00:00";
Excel::create($name, function ($excel) use($from, $to) {
$usersCount = User::count();
$predmetCount = Predmet::count();
$mjeraCount = Mjera::count();
$ucionicaCount = Ucionica::count();
$ulogaCount = Role::count();
$kategorijaCount = Kategorija::count();
$rezervacijaCount = 0;
$excel->setCreator('Hrvoje');
ini_set('max_execution_time', 120);
$excel->sheet(self::SHEET_NAME_USERS, function ($sheet) use($ulogaCount) {
$sheet->appendRow(array('ID', 'Ime', 'Broj mobitela', 'Email', 'Boja', 'ID uloge', 'Dodan', 'Zadnja promjena', 'Uloga'));
$i = 1;
foreach (User::select('id', 'name', 'broj_mobitela', 'email', 'boja', 'role_id', 'created_at', 'updated_at')->get() as $user) {
$i++;
$row = $user->toArray();
$row[] = self::getHyperlink(self::SHEET_NAME_ROLES, $ulogaCount, 'F' . $i);
$sheet->appendRow($row);
}
});
$excel->sheet(self::SHEET_NAME_ROLES, function ($sheet) {
$sheet->appendRow(array('ID', 'Ime uloge', 'Opis', 'Dodana', 'Zadnja promjena'));
$sheet->fromModel(Role::all(), null, 'A2', true, false);
});
$excel->sheet(self::SHEET_NAME_UCIONICE, function ($sheet) {
$sheet->appendRow(array('ID', 'Ime učionice', 'Najveći broj učenika', 'Adresa', 'Kat', 'Opis', 'Dodana', 'Zadnja promjena'));
$i = 1;
foreach (Ucionica::select('id', 'naziv', 'max_broj_ucenika', 'adresa', 'kat', 'opis', 'created_at', 'updated_at')->get() as $ucionica) {
$i++;
$row = $ucionica->toArray();
$sheet->appendRow($row);
}
});
$excel->sheet(self::SHEET_NAME_KATEGORIJE, function ($sheet) use($kategorijaCount) {
$sheet->appendRow(array('ID', 'Ime kategorije', 'ID nadkategorije', 'Dodana', 'Zadnja promjena', 'Nadkategorija'));
$i = 1;
foreach (Kategorija::select('id', 'ime', 'nadkategorija_id', 'created_at', 'updated_at')->get() as $kategorija) {
$i++;
$row = $kategorija->toArray();
$row[] = self::getHyperlink(self::SHEET_NAME_KATEGORIJE, $kategorijaCount, 'C' . $i);
$sheet->appendRow($row);
}
});
$excel->sheet(self::SHEET_NAME_PREDEMTI, function ($sheet) use($kategorijaCount) {
$sheet->appendRow(array('ID', 'Ime predmeta', 'ID kategorije', 'Dodana', 'Zadnja promjena', 'Kategorija'));
$i = 1;
foreach (Predmet::select('id', 'ime', 'kategorija_id', 'created_at', 'updated_at')->get() as $predmet) {
$i++;
$row = $predmet->toArray();
$row[] = self::getHyperlink(self::SHEET_NAME_KATEGORIJE, $kategorijaCount, 'C' . $i);
$sheet->appendRow($row);
}
});
$excel->sheet(self::SHEET_NAME_PREDEMT_USER, function ($sheet) use($predmetCount, $usersCount) {
$sheet->appendRow(array('ID djelatnika', 'ID predmeta', 'Djelatnik', 'Predmet'));
$i = 1;
foreach (DB::table('predmet_user')->select('user_id', 'predmet_id')->orderBy('user_id', 'predmet_id')->get() as $predmetUser) {
$i++;
$row = array();
$row[] = $predmetUser->user_id;
//.........这里部分代码省略.........