当前位置: 首页>>代码示例>>PHP>>正文


PHP Group::count方法代码示例

本文整理汇总了PHP中Group::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::count方法的具体用法?PHP Group::count怎么用?PHP Group::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group::count方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHasManyThrough

 public function testHasManyThrough()
 {
     $this->createUsersWithGroups(10, 5);
     $this->assertEqual(User::count(), 10);
     $this->assertEqual(Group::count(), 5);
     $this->assertEqual(UserAndGroupRelation::count(), 14);
     $user = User::findFirst(['conditions' => "login = 'login_1'"]);
     // Test has_many_through collection
     $queryCount = TipyDAO::$queryCount;
     $groups = $user->groups;
     // We got a 2 new querys
     $this->assertEqual(TipyDAO::$queryCount, $queryCount + 2);
     $this->assertNotEqual($groups, null);
     $this->assertEqual(sizeof($groups), 5);
     $this->assertEqual($groups[0]->name, 'name_1');
     // Test cached association
     $this->assertNotEqual($user->associationsCache["groups"], null);
     $this->assertEqual($groups, $user->associationsCache["groups"]);
     // Test no query
     $queryCount = TipyDAO::$queryCount;
     $groupsAgain = $user->groups;
     // no more queries
     $this->assertEqual(TipyDAO::$queryCount, $queryCount);
     $this->assertEqual($groups, $groupsAgain);
     // Test has many collection with conditions
     $groups = $user->groups(["order" => " name desc"]);
     $this->assertEqual(sizeof($groups), 5);
     $this->assertEqual($groups[0]->name, 'name_5');
     // Test queries association is not cached
     $this->assertNotEqual($groups, $user->associationsCache["groups"]);
 }
开发者ID:smetana,项目名称:tipy,代码行数:31,代码来源:AssociationsTest.php

示例2: render

 public function render()
 {
     if (isset($this->config['course_id'])) {
         $course = new Course();
         $course->include_related('period');
         $course->get_by_id((int) $this->config['course_id']);
         $this->parser->assign('course', $course);
         if ($course->exists()) {
             $task_sets = new Task_set();
             $task_sets->where_related($course);
             $task_sets->where('published', 1);
             $task_sets->where('content_type', 'task_set');
             $task_sets_count = $task_sets->count();
             $this->parser->assign('task_sets_count', $task_sets_count);
             $task_sets->where_related($course);
             $task_sets->where('published', 1);
             $task_sets->where('content_type', 'project');
             $projects_count = $task_sets->count();
             $this->parser->assign('projects_count', $projects_count);
             $groups = new Group();
             $groups->where_related($course);
             $groups_count = $groups->count();
             $this->parser->assign('groups_count', $groups_count);
             $students = new Student();
             $students->where_related('participant/course', 'id', $course->id);
             $students->where_related('participant', 'allowed', 1);
             $students_count = $students->count();
             $this->parser->assign('students_count', $students_count);
             $task_set_permissions = new Task_set_permission();
             $task_set_permissions->select_func('COUNT', '*', 'count');
             $task_set_permissions->where('enabled', 1);
             $task_set_permissions->where_related('task_set', 'id', '${parent}.id');
             $now = date('Y-m-d H:i:s');
             $plus_two_weeks = date('Y-m-d H:i:s', strtotime($now . ' + 2 weeks'));
             $minus_one_week = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
             $task_sets->select('id, name, upload_end_time AS min_upload_end_time, upload_end_time AS max_upload_end_time');
             $task_sets->where_related($course);
             $task_sets->where('published', 1);
             $task_sets->where_subquery('0', $task_set_permissions);
             $task_sets->where('upload_end_time >=', $minus_one_week);
             $task_sets->where('upload_end_time <=', $plus_two_weeks);
             $task_sets_2 = new Task_set();
             $task_sets_2->select('id, name');
             $task_sets_2->where_related($course);
             $task_sets_2->where('published', 1);
             $task_sets_2->select_min('task_set_permissions.upload_end_time', 'min_upload_end_time');
             $task_sets_2->select_max('task_set_permissions.upload_end_time', 'max_upload_end_time');
             $task_sets_2->where_related('task_set_permission', 'enabled', 1);
             $task_sets_2->having('(MAX(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MAX(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')');
             $task_sets_2->or_having('(MIN(`task_set_permissions`.`upload_end_time`) >= ' . $this->db->escape($minus_one_week) . ' AND MIN(`task_set_permissions`.`upload_end_time`) <= ' . $this->db->escape($plus_two_weeks) . ')');
             $task_sets_2->group_by('id');
             $task_sets->union_iterated($task_sets_2, FALSE, 'min_upload_end_time DESC, max_upload_end_time DESC', isset($this->config['number_of_task_sets']) ? (int) $this->config['number_of_task_sets'] : 5);
             $this->parser->assign('task_sets', $task_sets);
         }
     }
     $this->parser->parse('widgets/admin/course_overview/main.tpl');
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:57,代码来源:course_overview.php

示例3: run

 public function run()
 {
     if (Group::count('id')) {
         echo 'Skipping group seeder' . "\n";
         return;
     }
     $groups = [['title' => 'Ожидающий доступа', 'configs' => ['stars' => 0, 'title' => 'Ожидающий доступа', 'conf_show_signature' => false]], ['title' => 'Администратор', 'configs' => ['title' => 'Администратор']], ['title' => 'Newbie', 'configs' => ['stars' => 0, 'title' => 'Ньюбл', 'conf_show_signature' => false]], ['title' => 'Junior', 'configs' => ['stars' => 1, 'title' => 'Юниор']], ['title' => 'Member', 'configs' => ['stars' => 2, 'title' => 'Участник']], ['title' => 'Full Member', 'configs' => ['stars' => 3, 'title' => 'Уверенный пользователь']], ['title' => 'Senior Member', 'configs' => ['stars' => 4, 'title' => 'Сеньор']], ['title' => 'Profi', 'configs' => ['stars' => 5, 'title' => 'Профи']], ['title' => 'Master', 'configs' => ['stars' => 6, 'title' => 'Мастер']], ['title' => 'Guru', 'configs' => ['stars' => 7, 'title' => 'Гуру']], ['title' => 'Monster', 'configs' => ['stars' => 8, 'title' => 'Монстр']], ['title' => 'Wizard', 'configs' => ['stars' => 9, 'title' => 'Волшебник']], ['title' => 'God', 'configs' => ['stars' => 10, 'title' => 'Бог']], ['title' => 'Нарушившие правила', 'configs' => ['title' => 'Нарушитель', 'conf_show_signature' => false]], ['title' => 'Бан', 'configs' => ['title' => 'В бане', 'conf_show_signature' => false]], ['title' => 'Комодератор', 'configs' => ['title' => 'Помошник модератора']], ['title' => 'Модератор', 'configs' => ['title' => 'Модератор']], ['title' => 'Супермодератор', 'configs' => ['title' => 'Супермод']], ['title' => 'Ветеран', 'configs' => ['title' => 'Ветеран']], ['title' => 'Участники клуба Sources.RU', 'configs' => ['title' => 'Клубень']]];
     DB::transaction(function () use($groups) {
         foreach ($groups as $group) {
             Group::create($group);
         }
     });
 }
开发者ID:Developers-RuDev,项目名称:forum.next,代码行数:13,代码来源:GroupsTableSeeder.php

示例4: groups_list

 /**
  * View groups
  *
  * @param Request $request
  * @return mixed
  */
 public function groups_list(Request $request)
 {
     $filter = [];
     if ($request->order) {
         $filter['order'] = $request->order;
     }
     /** @var Listing $paginator */
     $paginator = NCService::load('Paginator.Listing', [$request->page, \Group::count()]);
     $filter = array_merge($filter, $paginator->limit());
     // Filter groups
     $groups = \Group::all($filter);
     $groups = array_map(function ($i) {
         return $i->to_array();
     }, $groups);
     return $this->view->render('users/groups.twig', ['title' => $this->lang->translate('user.groups'), 'groups_list' => $groups, 'listing' => $paginator->pages(), 'page' => $paginator->cur_page]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:22,代码来源:Control.php

示例5: insertGroup

 public function insertGroup()
 {
     $cre = ["group" => Input::get('group')];
     $rules = ["group" => 'required'];
     $validator = Validator::make($cre, $rules);
     if ($validator->passes()) {
         $group = new Group();
         $group->group_name = Input::get('group');
         $group->center_id = Input::get('center_id');
         $group->save();
         $group_info = Group::select('center.center_name', 'groups.group_name', 'city.city_name', 'groups.id')->join('center', 'groups.center_id', '=', 'center.id')->join('city', 'center.city_id', '=', 'city.id')->where('groups.id', '=', $group->id)->first();
         $count = Group::count();
         $data['success'] = 'true';
         $data['message'] = html_entity_decode(View::make('admin.manage.groups.view', ["data" => $group_info, "count" => $count]));
     } else {
         $data["success"] = false;
         $data["message"] = "All fields are not filled";
     }
     return json_encode($data);
 }
开发者ID:vishu87,项目名称:avyay_sms,代码行数:20,代码来源:AdminManageController.php

示例6: substr

$group->name = 'Yo! Ugly Group';
$group->date = '19001231';
$group->insert();
echo '<p>The "' . $group->name . '" have ID = ' . $group->id . '.</p>';
echo "<p>Oops... it's not " . substr($group->date, 0, 4) . " but 1999. Let's <b>update</b> it.</p>";
$group->date = '19991231';
$group->update();
echo "<p>Now we have the correct year: " . substr($group->date, 0, 4) . ".</p>";
$group->reset();
echo "<h1>Let's find the groups starting with Y</h1>";
$group->addWhere("name LIKE 'Y%'");
$group->addOrder("id");
$total = $group->find();
echo "<p>We've found " . $total . " groups starting with Y.</p>";
// we can use the count method to get the same result
if ($group->count() > 1) {
    while ($group->fetch()) {
        YDDebugUtil::dump($group->getValues());
    }
}
echo "<h1>But I really want is the first group.</h1>";
$group->reset();
$group->find(1);
YDDebugUtil::dump($group->getValues());
echo "<h1>And I don't like the 'Yo! Ugly Group, so I'll delete it. I will reset the object and execute a delete.</h1>";
$group->reset();
$group->delete();
echo "<p>A PHP notice saying that I have no conditions... This is a protection defined by the configuration<br>";
echo "YD_DATABASEOBJECT_DELETE. A similar configuration is available for UPDATEs that don't have conditions<br>";
echo "YD_DATABASEOBJECT_UPDATE. The default is false for both.</p>";
echo "<p>Let's set the ID.</p>";
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:31,代码来源:groups.php

示例7: countGroups

 public function countGroups($params = array())
 {
     if (!isset($params['status'])) {
         $params['status'] = 1;
     }
     if (!isset($params['is_delete'])) {
         $params['is_del'] = 0;
     }
     $model = new Group();
     $criteria = new CDbCriteria();
     $criteria->condition .= "1";
     $criteria->order = !empty($params['order']) ? $params['order'] : 't.ctime';
     if (!empty($limit)) {
         $criteria->limit = $limit;
     }
     if (!empty($params)) {
         $array = array('id', 'uid', 'cid0', 'cid1', 'type', 'status', 'is_del');
         foreach ($params as $key => $value) {
             if (in_array($key, $array)) {
                 $criteria->condition .= " and {$key}=:{$key}";
                 $criteria->params[':' . $key] = $value;
             }
         }
     }
     if (!empty($params['pageSize'])) {
         $pageSize = $params['pageSize'];
         $page = $params['page'];
         $_GET['page'] = $page;
         $total = $model->count($criteria);
         $pages = new CPagination($total);
         $pages->pageSize = $pageSize ? $pageSize : self::PAGE_SIZE;
         $pages->applyLimit($criteria);
     }
     $count = $model->count($criteria);
     return $count;
 }
开发者ID:vangogogo,项目名称:justsns,代码行数:36,代码来源:Group.php

示例8: actionAdmin

 /**
  * Lists all models.
  */
 public function actionAdmin()
 {
     $model = new Group('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Group'])) {
         $model->attributes = $_GET['Group'];
     }
     $this->render('admin', array('model' => $model, 'count' => $model->count()));
 }
开发者ID:BigMacckk,项目名称:kepsch,代码行数:13,代码来源:GroupController.php

示例9: set_paginate_options

 private function set_paginate_options()
 {
     $config = array();
     $config['base_url'] = site_url() . 'admin/groups';
     $config['use_page_numbers'] = TRUE;
     $config['per_page'] = 10;
     $config['total_rows'] = Group::count();
     $config['uri_segment'] = 3;
     $config['first_link'] = "<< " . lang('web_first');
     $config['first_tag_open'] = "<span class='pag'>";
     $config['first_tag_close'] = '</span>';
     $config['last_link'] = lang('web_last') . " >>";
     $config['last_tag_open'] = "<span class='pag'>";
     $config['last_tag_close'] = '</span>';
     $config['next_link'] = FALSE;
     $config['next_tag_open'] = "<span class='pag'>";
     $config['next_tag_close'] = '</span>';
     $config['prev_link'] = FALSE;
     $config['prev_tag_open'] = "<span class='pag'>";
     $config['prev_tag_close'] = '</span>';
     $config['cur_tag_open'] = "<span class='pag pag_active'>";
     $config['cur_tag_close'] = '</span>';
     $config['num_tag_open'] = "<span class='pag'>";
     $config['num_tag_close'] = '</span>';
     $config['full_tag_open'] = "<div class='navigation'>";
     $config['full_tag_close'] = '</div>';
     $choice = $config["total_rows"] / $config["per_page"];
     //$config["num_links"] = round($choice);
     return $config;
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:30,代码来源:groups.php


注:本文中的Group::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。