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


PHP CriteriaCompo::setGroupby方法代码示例

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


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

示例1: getCategoryList

 public function getCategoryList($uid = 0)
 {
     $criteria = new CriteriaCompo();
     if (!empty($uid)) {
         $criteria->add(new Criteria("uid", $uid));
     }
     $criteria->setOrder("ASC");
     $criteria->setSort("cat_id");
     $categories = $this->getAll($criteria);
     $catarr = array();
     if ($this->getCount($criteria)) {
         unset($criteria);
         $topic_handler = xoops_getmodulehandler("topics", "press");
         $criteria = new CriteriaCompo(new Criteria("cat_id", "(" . implode(",", array_keys($categories)) . ")", "in"));
         if (!empty($uid)) {
             $criteria->add(new Criteria("uid", $uid));
         }
         $criteria->setGroupby("cat_id");
         $counts = $topic_handler->getCounts($criteria);
         foreach ($categories as $key => $obj) {
             $catarr[$key]["cat_name"] = $obj->getVar("cat_name");
             $catarr[$key]["cat_id"] = $key;
             if (!empty($uid)) {
                 $catarr[$key]["uid"] = $uid;
             }
             $catarr[$key]["cat_topics"] = isset($counts[$key]) ? $counts[$key] : 0;
         }
         return $catarr;
     }
 }
开发者ID:yunsite,项目名称:xoopsdc,代码行数:30,代码来源:category.php

示例2: array

 /**
  * recalc rankings of sql body part
  *
  * @access protected
  * @param object &$add_days_criteria
  * @param object &$sub_days_criteria
  * @param bool $update_sum flag for update sum tables
  * @return bool false if failure
  */
 function _recalc_sql(&$add_days_criteria, &$sub_days_criteria, $update_sum)
 {
     global $xoopsDB;
     $config_names = array('visible', 'new_visible', 'num_rows', 'new_num_rows');
     $config = array();
     foreach ($config_names as $name) {
         $config[$name] = $this->_get_config($name);
     }
     $config['visible'] = explode(',', $config['visible']);
     $config['new_visible'] = explode(',', $config['new_visible']);
     // days criteria
     $days_criteria = new CriteriaCompo();
     $days_criteria->add($add_days_criteria);
     if ($sub_days_criteria->render() != '') {
         $days_criteria->add($sub_days_criteria, 'OR');
     }
     $add_days_sql = $add_days_criteria->render();
     if ($add_days_sql == '') {
         $add_days_sql = '0';
     }
     $sub_days_sql = $sub_days_criteria->render();
     if ($sub_days_sql == '') {
         $sub_days_sql = '0';
     }
     $etids = array();
     if ($config['visible'][0] || $update_sum) {
         $etids[] = ETID_VIEW_ITEM;
     }
     if ($config['visible'][1] || $update_sum) {
         $etids[] = ETID_DOWNLOAD_FILE;
     }
     if ($config['visible'][2] || $update_sum) {
         $etids[] = ETID_CERTIFY_ITEM;
     }
     if ($config['visible'][3] || $update_sum) {
         $etids[] = ETID_QUICK_SEARCH;
         $etids[] = ETID_ADVANCED_SEARCH;
     }
     if ($config['visible'][4] || $update_sum) {
         $etids[] = ETID_REQUEST_CERTIFY_ITEM;
     }
     $new_etids = array();
     if ($config['new_visible'][0] || $update_sum) {
         $new_etids[] = ETID_CERTIFY_ITEM;
     }
     if ($config['new_visible'][1] || $update_sum) {
         $new_etids[] = ETID_INSERT_GROUP;
     }
     $sum = $update_sum ? 'sum_' : '';
     $log_table = $xoopsDB->prefix('xoonips_event_log');
     $new_group_table = $xoopsDB->prefix('xoonips_ranking_' . $sum . 'new_group');
     $new_item_table = $xoopsDB->prefix('xoonips_ranking_' . $sum . 'new_item');
     if (count($etids)) {
         $etids_str = '(' . implode(',', $etids) . ')';
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('event_type_id', $etids_str, 'IN'));
         $criteria->add($days_criteria);
         $cnt = $this->handlers['event_log']->getCount($criteria);
         if ($cnt) {
             // log changed. need recalc.
             // ranking viewed item
             if ($config['visible'][0] || $update_sum) {
                 $etid = ETID_VIEW_ITEM;
                 $basename = $sum . 'viewed_item';
                 $fields = 'tb.item_id, SUM(' . $add_days_sql . ') - SUM(' . $sub_days_sql . ') AS count';
                 $criteria = new CriteriaCompo();
                 $criteria->add(new Criteria('event_type_id', $etid));
                 $criteria->add($days_criteria);
                 $criteria->setGroupby('tb.item_id');
                 $join_criteria = new XooNIpsJoinCriteria('xoonips_item_basic', 'item_id', 'item_id', 'INNER', 'tb');
                 $res =& $this->handlers['event_log']->open($criteria, $fields, false, $join_criteria);
                 while ($obj =& $this->handlers['event_log']->getNext($res)) {
                     $item_id = $obj->getVar('item_id', 'n');
                     $delta = $obj->getExtraVar('count');
                     if (!$this->handlers[$basename]->increment($item_id, $delta)) {
                         die('fatal error in ' . __FILE__ . ' at ' . __LINE__);
                     }
                 }
                 $this->handlers['event_log']->close($res);
             }
             // ranking downloaded item
             if ($config['visible'][1] || $update_sum) {
                 $etid = ETID_DOWNLOAD_FILE;
                 $basename = $sum . 'downloaded_item';
                 $fields = 'tb.item_id, SUM(' . $add_days_sql . ') - SUM(' . $sub_days_sql . ') AS count';
                 $criteria = new CriteriaCompo();
                 $criteria->add(new Criteria('event_type_id', $etid));
                 $criteria->add($days_criteria);
                 $criteria->setGroupby('tb.item_id');
                 $join_criteria = new XooNIpsJoinCriteria('xoonips_item_basic', 'item_id', 'item_id', 'INNER', 'tb');
                 $res =& $this->handlers['event_log']->open($criteria, $fields, false, $join_criteria);
//.........这里部分代码省略.........
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:101,代码来源:xoonips_ranking.class.php

示例3: CriteriaCompo

    $visibility = $visibility_handler->create();
    $visibility->setVar('field_id', $_REQUEST['field_id']);
    $visibility->setVar('user_group', $_REQUEST['ug']);
    $visibility->setVar('profile_group', $_REQUEST['pg']);
    $visibility_handler->insert($visibility, true);
}
if ($op == "del") {
    $criteria = new CriteriaCompo(new Criteria('field_id', intval($_REQUEST['field_id'])));
    $criteria->add(new Criteria('user_group', intval($_REQUEST['ug'])));
    $criteria->add(new Criteria('profile_group', intval($_REQUEST['pg'])));
    $visibility_handler->deleteAll($criteria, true);
    redirect_header("visibility.php", 2, sprintf(_PROFILE_AM_DELETEDSUCCESS, _PROFILE_AM_PROF_VISIBLE));
    exit;
}
$criteria = new CriteriaCompo();
$criteria->setGroupby("field_id, user_group, profile_group");
$visibilities = $visibility_handler->getAll($criteria);
$member_handler = xoops_gethandler('member');
$groups = $member_handler->getGroupList();
$groups[0] = _PROFILE_AM_FIELDVISIBLETOALL;
asort($groups);
$GLOBALS['xoopsTpl']->assign('fields', $fields);
$GLOBALS['xoopsTpl']->assign('visibilities', $visibilities);
$GLOBALS['xoopsTpl']->assign('groups', $groups);
$add_form = new XoopsSimpleForm('', 'addform', 'visibility.php');
$sel_field = new XoopsFormSelect(_PROFILE_AM_FIELDVISIBLE, 'field_id');
$sel_field->setExtra("style='width: 200px;'");
$sel_field->addOptionArray($fields);
$add_form->addElement($sel_field);
$sel_ug = new XoopsFormSelect(_PROFILE_AM_FIELDVISIBLEFOR, 'ug');
$sel_ug->addOptionArray($groups);
开发者ID:gauravsaxena21,项目名称:simantz,代码行数:31,代码来源:visibility.php

示例4: array

 function _findDuplicateItemIds($item)
 {
     //Item A:title=A,B,C,C
     //Item B:title=A,B,B,C
     //Item C:title=A,B,C
     //Item D:title=A,B,C,C
     //
     //Item A != Item B
     //Item A != Item C
     //Item A == Item D
     //Item B != Item C
     //Item B != Item D
     //Item C != Item D
     global $xoopsDB, $xoopsUser;
     $basic =& $item->getVar('basic');
     $title_handler =& xoonips_getormhandler('xoonips', 'title');
     $titles = array();
     foreach ($item->getVar('titles') as $title) {
         if (array_key_exists($title->get('title'), $titles)) {
             $titles[$title->get('title')]++;
         } else {
             $titles[$title->get('title')] = 1;
         }
     }
     // title matching
     // select item that has same number of each titles
     //
     $item_ids = array();
     foreach ($titles as $title => $count) {
         $criteria = new CriteriaCompo(new Criteria('title', $title));
         $criteria->add(new Criteria('item_type_id', $basic->get('item_type_id')));
         $criteria->add(new Criteria('uid', $xoopsUser->getVar('uid')));
         if (count($item_ids) > 0) {
             $criteria->add(new Criteria('tb.item_id', '(' . implode(',', $item_ids) . ')', 'IN'));
         }
         $criteria->setGroupby('tb.item_id,title having count(*)=' . $count);
         $join = new XooNIpsJoinCriteria('xoonips_item_basic', 'item_id', 'item_id', 'LEFT', 'tb');
         $results =& $title_handler->getObjects($criteria, false, '*, count(*)', null, $join);
         $item_ids = array();
         foreach ($results as $result) {
             $item_ids[] = $result->get('item_id');
         }
     }
     if (count($item_ids) == 0) {
         // return only doi conflict item id
         // if no conflict items of title matching
         return $this->_findDoiConflictItemIds($item);
     }
     //
     // select item that has same number of title
     //
     $criteria = new Criteria('item_id', '(' . implode(',', $item_ids) . ')', 'IN');
     $criteria->setGroupby('item_id having count(*)=' . count($item->getVar('titles')));
     $titles =& $title_handler->getObjects($criteria);
     if (count($titles) == 0) {
         return array();
     }
     // no conflict item
     $item_ids = array();
     foreach ($titles as $title) {
         $item_ids[] = $title->get('item_id');
     }
     $ids = array_unique(array_merge($item_ids, $this->_findDoiConflictItemIds($item)));
     return $ids;
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:65,代码来源:xoonips_import_item.class.php

示例5: getCertifiedGroupItemIds

 /** get ids of group-certified item. 
  * @param gid
  * @return item_id[]
  */
 function getCertifiedGroupItemIds($gid)
 {
     $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
     $join = new XooNIpsJoinCriteria('xoonips_index', 'index_id', 'index_id');
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('gid', $gid));
     $criteria->add(new Criteria('open_level', OL_GROUP_ONLY));
     $criteria->add(new Criteria('certify_state', CERTIFIED));
     $criteria->setGroupby('item_id');
     $index_item_links =& $index_item_link_handler->getObjects($criteria, false, 'item_id', false, $join);
     $iids = array();
     foreach ($index_item_links as $link) {
         $iids[] = $link->get('item_id');
     }
     return $iids;
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:20,代码来源:logic.class.php


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