本文整理汇总了PHP中User::count方法的典型用法代码示例。如果您正苦于以下问题:PHP User::count方法的具体用法?PHP User::count怎么用?PHP User::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$totalQuizzesCount = Quiz::count();
$totalUsersCount = User::count();
$todayQuizzesCount = Quiz::whereRaw('DATE(created_at) = DATE(NOW())')->count();
$todayUsersCount = User::whereRaw('DATE(created_at) = DATE(NOW())')->count();
$overallActivities = QuizUserActivity::groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
$overallStats = array();
foreach ($overallActivities as $activity) {
$overallStats[$activity['type']] = $activity['count'];
}
$overallStats['quizzes'] = $totalQuizzesCount;
$overallStats['users'] = $totalUsersCount;
$todayActivities = QuizUserActivity::whereRaw('DATE(created_at) = DATE(\'' . date('Y-m-d H:i:s') . '\')')->groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
$todayStats = array();
foreach ($todayActivities as $activity) {
$todayStats[$activity['type']] = $activity['count'];
}
$todayStats['quizzes'] = $todayQuizzesCount;
$todayStats['users'] = $todayUsersCount;
//Filling stats vars that are not yet set
self::fillNullStats($todayStats);
self::fillNullStats($overallStats);
View::share(array('overallStats' => $overallStats, 'todayStats' => $todayStats));
$last30DaysActivity = self::getLastNDaysActivity(30, 'attempt');
$last30DaysUserRegistrations = self::getLastNDaysUserRegistrations(30);
View::share(array('last30DaysActivity' => json_encode($last30DaysActivity), 'last30DaysUserRegistrations' => json_encode($last30DaysUserRegistrations)));
return View::make('admin/index');
}
示例2: index
/**
* Список пользователей
*/
public function index()
{
$list = Request::input('list', 'all');
$login = Request::input('login');
if (Request::isMethod('post')) {
$users = User::all(array('select' => 'login', 'order' => 'point DESC, login ASC'));
foreach ($users as $key => $val) {
if (strtolower($login) == strtolower($val->login)) {
$position = $key + 1;
}
}
if (isset($position)) {
$page = ceil($position / Setting::get('users_per_page'));
App::setFlash('success', 'Позиция в рейтинге: ' . $position);
App::redirect("/users?page={$page}&login={$login}");
} else {
App::setFlash('danger', 'Пользователь с данным логином не найден!');
}
}
$count['users'] = $total = User::count();
$count['admins'] = User::count(['conditions' => ['level in (?)', ['moder', 'admin']]]);
$condition = [];
if ($list == 'admins') {
$total = $count['admins'];
$condition = ['level IN(?)', ['moder', 'admin']];
}
$page = App::paginate(Setting::get('users_per_page'), $total);
$users = User::all(array('conditions' => $condition, 'offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'point DESC, login ASC'));
App::view('users.index', compact('users', 'page', 'count', 'list', 'login'));
}
示例3: testDeleteUser
public function testDeleteUser()
{
$count = User::count();
$this->delete('delete', array(), array('id' => $this->user->id), array('user' => $this->user->id));
$this->assertEquals($count - 1, User::count(array('cache' => false)));
$this->assertRedirect('http://' . DOMAIN);
}
示例4: filter
public function filter()
{
$string = '%' . $this->input->post('string') . '%';
$a = array();
if ($string) {
$a = User::find('all', array('conditions' => array('nombre LIKE ? OR apellido LIKE ? OR usuario LIKE ?', $string, $string, $string)));
} else {
$a = User::find('all');
}
$this->table->set_heading('Usuario', 'Nombre', 'Apellido', 'Teléfono', 'Celular', 'Email', 'Dirección', 'Acciones');
foreach ($a as $al) {
$this->table->add_row($al->usuario, $al->nombre, $al->apellido, $al->telefono, $al->celular, $al->email, $al->direccion, anchor('usuarios/ver/' . $al->id, img('static/img/icon/doc_lines.png'), 'class="tipwe" title="Ver detalles de usuario"') . ' ' . anchor('usuarios/editar/' . $al->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar usuario"') . ' ' . anchor('usuarios/eliminar/' . $al->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar usuario"'));
}
echo $this->table->generate();
$config['base_url'] = site_url('usuarios/index');
$config['total_rows'] = User::count();
$config['per_page'] = '10';
$config['num_links'] = '10';
$config['first_link'] = '← primero';
$config['last_link'] = 'último →';
$this->load->library('pagination', $config);
echo '<div class="pagination">';
echo $this->pagination->create_links();
echo '</div>';
}
示例5: run
public function run()
{
$model = new User();
//审核状态
$user_status = array('all' => '所有', User::STATUS_AUDIT => '待审核', User::STATUS_DISABLE => '禁用', User::STATUS_NORMAL => '正常');
//条件
$criteria = new CDbCriteria();
$groupid = intval(Yii::app()->request->getParam('groupid'));
$username = trim(Yii::app()->request->getParam('username'));
$status = Yii::app()->request->getParam('status', 'all');
$groupid > 0 && $criteria->addColumnCondition(array('groupid' => $groupid));
if ($status != 'all') {
$criteria->addSearchCondition('status', $status);
}
$criteria->addSearchCondition('username', $username);
$criteria->order = 'uid ASC';
$count = $model->count($criteria);
//分页
$pages = new CPagination($count);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
//查询
$result = $model->findAll($criteria);
$this->controller->render('index', array('datalist' => $result, 'pagebar' => $pages, 'status' => $status, 'user_status' => $user_status));
}
示例6: index
public function index($request)
{
$data = [];
$counts = [];
$counts['videos'] = Video::count();
$counts['users'] = User::count();
$counts['channels'] = UserChannel::count();
$counts['comments'] = Comment::count();
$counts['total_views'] = Video::sumViews();
$counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2);
$counts['videos_that_has_comments'] = Statistic::countVideosHavingComments();
$counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count;
$counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2);
$counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2);
$counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1');
$counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2');
$counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3');
$counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3');
$counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2);
$counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2);
$counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2);
$counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2);
$data['counts'] = $counts;
return new ViewResponse('admin/statistic/index', $data);
}
示例7: init
public function init($id_tovar)
{
$data = $_REQUEST;
$join = "INNER JOIN koncentrator_tovarishestvo c ON(user.concetrator = c.name_konc)";
$this->_Users = User::all(array('conditions' => array("is_admin <> ? and id_tovar= ?", 1, $id_tovar), 'joins' => $join));
$this->id_tovar = $id_tovar;
/* if (!isset($data[Users::PAGE])) {
$this->_Users = User::find('all', array('limit' => 2), array('conditions' => "is_admin <> 1"));
//var_dump($_Users);
} else {
$this->_Users = User::find('all', array('conditions' => "is_admin <> 1", 'limit' => 2, 'offset' => (($data[Users::PAGE] * 2) - 2)));
//var_dump($_Users);
} */
$this->countPage = ceil(User::count(array('conditions' => "is_admin <> 1")) / 2);
if (isset($data[self::BUTTON_DELETE])) {
$User = User::find_by_login($data['login']);
if ($User instanceof User) {
$User->delete();
Flight::redirect('/admin/users/' . $this->id_tovar . '?success=3');
}
}
if (isset($data['saveUser'])) {
if ($data['idUser'] === 'newUser') {
return $this->addNewUser();
} else {
return $this->changeUser();
}
}
}
示例8: getUsers
public function getUsers(Request $request)
{
$yetkiler = Role::all();
$count = $request->get('count');
$page = $request->get('page');
$filters = $request->get('filter');
$sorting = $request->get('sorting');
$results = new User();
if (is_array($filters)) {
foreach ($filters as $key => $filter) {
$results = $results->where($key, 'like', "%" . urldecode($filter) . "%");
}
}
if (is_array($sorting)) {
foreach ($sorting as $key => $sort) {
$results = $results->orderBy($key, $sort);
}
} else {
$results = $results->orderBy('id', 'desc');
}
if ($request->has('count') && $request->has('page')) {
$results = $results->skip($count * ($page - 1))->take($count);
}
$results = $results->get();
$filter_yetkiler = Role::select('id', 'display_name as title')->get();
return array('results' => $results, 'inlineCount' => User::count(), 'yetkiler' => $yetkiler, 'filter_yetkiler' => $filter_yetkiler);
}
示例9: reset_pass
public function reset_pass($token = null)
{
if (empty($token)) {
redirect('forgot_pass');
} else {
if (User::count(array('conditions' => array('pass_key = ?', $token))) == 0) {
redirect('forgot_pass');
}
}
$this->data['token'] = $token;
$this->data['user'] = User::find_by_pass_key($token);
if ($_POST) {
if ($this->form_validation->run('pass_reset') == FALSE) {
$this->content_view = 'forgot_pass/reset_pass';
$this->data['error'] = true;
} else {
$this->data['user']->password = crypt($this->input->post('pass') . $this->data['user']->salt);
$this->data['user']->pass_key = "";
$this->data['user']->save();
$this->content_view = 'forgot_pass/reset_pass_confirm';
}
} else {
$this->content_view = "forgot_pass/reset_pass";
}
}
示例10: testDestroy
public function testDestroy()
{
$user = Factory::create('User');
$this->action('DELETE', 'Admin\\UsersController@destroy', $user->id);
$this->assertRedirectedToRoute('admin.users.index');
$this->assertEquals(0, User::count());
}
示例11: index
public function index()
{
$total = User::count();
$users = User::orderby('id')->paginate(10);
$this->layout->title = "Users";
$this->layout->content = View::make('users.index', compact('users', 'total'));
}
示例12: indexAction
public function indexAction()
{
header("Content-type: text/html; charset=utf-8");
//查询条件
$condition = '';
$data_count = User::count($condition);
$page_num = 5;
$current_page = (int) $_GET["page"];
//分页处理
$pagination = Tools::pagination($data_count, $page_num, $current_page);
//分页条件
$limit = array("limit" => array("number" => $page_num, "offset" => $pagination->offset));
//获取数据
$list = User::find($limit);
//结果展示
foreach ($list as $item) {
echo $item->id . ':' . $item->name . '<br/>';
}
//数字分页展示
for ($i = 1; $i <= $pagination->maxPage; $i++) {
echo "<a href='?page={$i}'>{$i}</a> ";
}
//翻页展示
echo "<a href='?page=1'>首页</a> ";
echo "<a href='?page={$pagination->prePage}'>上一页</a> ";
echo "<a href='?page={$pagination->nextPage}'>下一页</a> ";
echo "<a href='?page={$pagination->maxPage}'>尾页</a> ";
//TODO 当前页为首页或尾页时A标签的状态处理
die;
}
示例13: to_array
public function to_array()
{
$array = parent::to_array();
$array['use_admin'] = $this->can('use_admin');
$array['users'] = User::count(['conditions' => ['group_id = ?', $this->id]]);
return $array;
}
示例14: index
public function index()
{
$contacts_count = Contact::count();
$users_count = User::count();
$data = array("contacts_count" => $contacts_count, "contacts_count" => $contacts_count);
return View::make('admin.index', $data);
}
示例15: dashboard
public function dashboard()
{
$counts = ['organizations' => Organization::count(), 'users' => User::count(), 'todos' => Todo::count(), 'mt_users' => User::has('organizations', '>', 1)->count()];
$newestOrg = Organization::orderBy('created_at', 'desc')->first();
$orgWithMostTodos = DB::table('organizations')->select(['organizations.name', DB::raw('count(todos.organization_id) as total')])->join('todos', 'todos.organization_id', '=', 'organizations.id')->orderBy('total', 'desc')->groupBy('todos.organization_id')->first();
$this->view('dashboard', compact('counts', 'newestOrg', 'orgWithMostTodos'));
}