Documentation

GetList

Description and parameters

CDBResult
CCatalog::GetList(
 array arOrder = array(),
 array arFilter = array(),
 array arGroupBy = false,
 array arNavStartParams = false,
 array arSelectFields = array()
);

Method retrieves records from catalog according to its parameters. Non-static method.

Call parameters

ParameterDescription
arOrder Array to sort resulting records. Array has the appearance:
array(
"field_name1" => "sort_direction1",
"field_name2" => "sort_direction2",
. . .
)
The "field_nameN" can have any catalog field and as "sort_directionX" can have values "ASC" (by ascension) and "DESC" (by descension).

If sorting array has several elements, resulting set is sorted sequentially by each element (i. e. first sorts by the first element, then sorts result by second and etc.). 

Default value - empty array() - indicates that result won't be sorted.
arFilter Array to perform sorting catalog records. Array has appearance:
array(
"[modifier1][operator1]field_name1" => "value1",
"[modifier2][operator2]field_name2" => "value2",
...
)
Records that satisfy the filter are returned in the result and records that doesn't satisfy filter conditions are not included.

The following modifiers are deemed as permissible:
  • ! - negation;
  • + - values null, 0 and empty string also satisfy filter conditions.
The operators are deemed as permissible:
  • >= - field value is higher or equal to the value passed to filter;
  • > - field value is strictly higher then value passed to filter;
  • <= - field value is less or equal to value passed to filter;
  • < - field value is strictly less than value passed to filter;
  • @ - operator can be used for in integer and real data when passing set of values (array). In this case, hen generating SQL query uses the SQL operatorIN, producing record form;
  • ~ - field value is checked for comparison to the template passed to filter;
  • % - field value is checked for comparison to the string passed to filter according to query language.
The "field_anemX" can have any catalog field.

Filter example:
array("SUBSCRIPTION" => "Y")
This filter indicates "select all records, for the field SUBSCRIPTION value ("Content selling" flag) is Y".

Default value - empty array() - indicates that result is filtered or not.
arGroupBy Array with fields for coupon grouping. Has the appearance:
array("field_name1", "field_names", . . .)
"field_nameN" can have any catalog field.

In case array is empty, method returns number of records satisfying the filter.
Default value - false - indicates that the result won't be grouped.
arNavStartParams Array with selection parameters. Can contain the following keys:
  • "nTopCount" - number of returned records will be limited from top by this key;
  • any key, received by method CDBResult::NavQuery as the third parameter.
Default value - false - indicates no parameters for retrieved result.
arSelectFields Array with record fields to be returned by the method. You can indicate only the required fields. When array has the value "*", returns all available fields.

Default value - empty array array() - indicates all fields of the main query table to be returned.

Returned values

Method returns CDBResult class object, containing collection of associative arrays with keys:

Key Description
ID Catalog code. Matches with iblock code.
IBLOCK_ID Iblock code.
IBLOCK_TYPE_ID Iblock type.
SUBSCRIPTION Flag "Selling content".
NAME Iblock name.

If passes an empty array as the parameter arGroupBy, the method returns number of records satisfying the filter.


© «Bitrix24», 2001-2024
Up