GetList
CDBResult CGroup::GetList( string &by = "c_sort", string &order = "asc", array filter, string SHOW_USERS_AMOUNT = "N" )
The method returns list of groups as an object of CDBResult class. Static method.
Parameters
Parameter | Description | Available from version |
---|---|---|
by | Reference to the variable containing the sorting field. The following values are possilble:
| |
оrder | Reference to the variable containing the sort order. The following values are possible:
| |
filter | An array used to filter users. The following keys are possible:
| |
SHOW_USERS_AMOUNT | If set to "Y", the selection will include the field "USERS" containing the number of users in the group; if set to "N", the selection will not include such field (default behaviour). | 3.3.12 |
See Also
Examples of use
<? $filter = Array ( "ID" => "1 | 2", "TIMESTAMP_1" => "04.02.2004", // in the format of the current site "TIMESTAMP_2" => "04.02.2005", "ACTIVE" => "Y", "NAME" => "Techsupport", "DESCRITION" => "special | support", "USERS_1" => "2", // from 2 users "USERS_2" => "10" // to 10 users ); $rsGroups = CGroup::GetList(($by="c_sort"), ($order="desc"), $filter); // select groups $is_filtered = $rsGroups->is_filtered; // whether the selection is filtered $rsGroups->NavStart(50); // paginate by 50 records echo $rsGroups->NavPrint(GetMessage("PAGES")); // display per page navigation while($rsGroups->NavNext(true, "f_")) : echo "[".$f_ID."] ".$f_NAME." ".$f_DESCRIPTION."<br>"; endwhile; ?>
Filtering can be dove by "STRING_ID" field - group ID. For example:
// Returns group by the ID function GetGroupByCode ($code) { $rsGroups = CGroup::GetList ($by = "c_sort", $order = "asc", Array ("STRING_ID" => $code)); return $rsGroups->Fetch(); }
Examples of filtering by the "STRING_ID" field by several groups:
$rsGroups = CGroup::GetList($by = "c_sort", $order = "asc", array("STRING_ID"=>'groupe code|groupe code|groupe code')); if(intval($rsGroups->SelectedRowsCount()) > 0) { while($arGroups = $rsGroups->Fetch()) { $arUsersGroups[] = $arGroups; } }
© «Bitrix24», 2001-2024