本文整理汇总了PHP中Criteria::setGroupby方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::setGroupby方法的具体用法?PHP Criteria::setGroupby怎么用?PHP Criteria::setGroupby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::setGroupby方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountPublications
/**
* count user defined publications
*
* @access public
* @param int $uid user id
* @return array publication count by item type id
*/
function getCountPublications($uid)
{
$join = new XooNIpsJoinCriteria('xoonips_item_basic', 'item_id', 'item_id', 'INNER', 'ib');
$criteria = new Criteria('uid', $uid, '=', $this->db->prefix($this->__table_name));
$criteria->setGroupby('ib.item_type_id');
$res = $this->open($criteria, 'item_type_id, COUNT(DISTINCT ib.item_id)', false, $join);
$nums = array();
while ($obj =& $this->getNext($res)) {
$item_type_id = $obj->getExtraVar('item_type_id');
$count = $obj->getExtraVar('COUNT(DISTINCT ib.item_id)');
$nums[$item_type_id] = $count;
}
$this->close($res);
return $nums;
}
示例2: CriteriaCompo
$criteria = new CriteriaCompo();
$count = $handler->getCount($criteria);
$start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0;
$limit = 20;
$criteria->setStart($start);
$criteria->setLimit($limit);
if (isset($sortby) && $sortby != "") {
$criteria->setSort($sortby);
$criteria->setOrder($order);
}
$objects =& $handler->getObjects($criteria, true, false);
unset($criteria);
if (count($objects) > 0) {
$xoopsTpl->assign('objects', $objects);
$criteria = new Criteria('newsletterid', "(" . implode(',', array_keys($objects)) . ")", "IN");
$criteria->setGroupby("newsletterid");
$subscriber_handler = xoops_getmodulehandler('subscriber');
$xoopsTpl->assign('receiver_counts', $subscriber_handler->getCount($criteria));
}
$smartOption['template_main'] = $typetemplate;
if ($count > $limit) {
include_once XOOPS_ROOT_PATH . "/class/pagenav.php";
$nav = new XoopsPageNav($count, $limit, $start, "start");
$xoopsTpl->assign("pagenav", $nav->renderNav(20));
}
/**
* Implementing the SmartObject Table
* Tobe continued...
*/
/*
include_once SMARTOBJECT_ROOT_PATH."class/smartobjecttable.php";
示例3: 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;
}
示例4: array
$criteria->setSort(array('meta_key', 'meta_id'));
$postmetaObjects =& $postmetaHandler->getObjects($criteria);
$postmetaRows = array();
if ($postmetaObjects) {
$_style = "";
foreach ($postmetaObjects as $postmetaObject) {
$_style = 'class="odd"' == $_style ? 'class="even"' : 'class="odd"';
$postmetaRow =& $postmetaObject->getVarArray("e");
$postmetaRow['style'] = $_style;
$postmetaRows[] =& $postmetaRow;
}
}
$criteria = new Criteria(1, 1);
$criteria->setSort('meta_id');
$criteria->setOrder('DESC');
$criteria->setGroupby('meta_key');
$postmetaKeys = array();
$postmetakeyObjects =& $postmetaHandler->getObjects($criteria, false);
if ($postmetakeyObjects) {
foreach ($postmetakeyObjects as $postmetakeyObject) {
$postmetaKeys[] = $postmetakeyObject->getVar('meta_key');
}
}
$_wpTpl =& new WordPresTpl('wp-admin');
$_wpTpl->assign('user_ID', $user_ID);
$_wpTpl->assign('user_level', $user_level);
$_wpTpl->assign('post_ID', $post_ID);
$_wpTpl->assign('post_status', $post_status);
$_wpTpl->assign('post_password', $post_password);
$_wpTpl->assign('mode', $mode);
$_wpTpl->assign('edited_post_title', $edited_post_title);