本文整理汇总了PHP中CRM_Contact_DAO_Group::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Group::orderBy方法的具体用法?PHP CRM_Contact_DAO_Group::orderBy怎么用?PHP CRM_Contact_DAO_Group::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_DAO_Group
的用法示例。
在下文中一共展示了CRM_Contact_DAO_Group::orderBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroups
/**
* Returns array of group object(s) matching a set of one or Group properties.
*
* @param array $params
* Limits the set of groups returned.
* @param array $returnProperties
* Which properties should be included in the returned group objects.
* (member_count should be last element.)
* @param string $sort
* @param int $offset
* @param int $rowCount
*
* @return array
* Array of group objects.
*
*
* @todo other BAO functions that use returnProperties (e.g. Query Objects) receive the array flipped & filled with 1s and
* add in essential fields (e.g. id). This should follow a regular pattern like the others
*/
public static function getGroups($params = NULL, $returnProperties = NULL, $sort = NULL, $offset = NULL, $rowCount = NULL)
{
$dao = new CRM_Contact_DAO_Group();
if (!isset($params['is_active'])) {
$dao->is_active = 1;
}
if ($params) {
foreach ($params as $k => $v) {
if ($k == 'name' || $k == 'title') {
$dao->whereAdd($k . ' LIKE "' . CRM_Core_DAO::escapeString($v) . '"');
} elseif ($k == 'group_type') {
foreach ((array) $v as $type) {
$dao->whereAdd($k . " LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . (int) $type . CRM_Core_DAO::VALUE_SEPARATOR . "%'");
}
} elseif (is_array($v)) {
foreach ($v as &$num) {
$num = (int) $num;
}
$dao->whereAdd($k . ' IN (' . implode(',', $v) . ')');
} else {
$dao->{$k} = $v;
}
}
}
if ($offset || $rowCount) {
$offset = $offset > 0 ? $offset : 0;
$rowCount = $rowCount > 0 ? $rowCount : 25;
$dao->limit($offset, $rowCount);
}
if ($sort) {
$dao->orderBy($sort);
}
// return only specific fields if returnproperties are sent
if (!empty($returnProperties)) {
$dao->selectAdd();
$dao->selectAdd(implode(',', $returnProperties));
}
$dao->find();
$flag = $returnProperties && in_array('member_count', $returnProperties) ? 1 : 0;
$groups = array();
while ($dao->fetch()) {
$group = new CRM_Contact_DAO_Group();
if ($flag) {
$dao->member_count = CRM_Contact_BAO_Group::memberCount($dao->id);
}
$groups[] = clone $dao;
}
return $groups;
}