public static function getList($arParams, $showSql = false) { $query = new Entity\Query("select"); $arMap = static::getMapArray(); $query->setTableMap($arMap); $tableName = static::getTableName(); $query->setTableName($tableName); $primaryField = static::getPrimaryField(); $query->setPrimaryKey($primaryField); foreach ($arParams as $field => $values) { switch ($field) { case 'select': $query->setSelect($values); break; case 'filter': $query->setFilter($values); $query->setWhere(); break; case 'group': $query->setGroup($values); break; case 'order': $query->setOrder($values); break; case 'limit': $query->setLimit($values); break; case 'offset': $query->setOffset($values); break; case 'runtime': $query->setRuntime($values); break; } } $arOrder = $query->getOrder(); if (empty($arOrder)) { $arOrder = array($primaryField => "ASC"); $query->setOrder($arOrder); } $res = $query->exec(); $arResult = array(); while ($ar_res = $res->fetch()) { $arResult[] = $ar_res; } if (!empty($arResult)) { $tmpResult = $arResult; $arResult = array(); for ($i = 0; $i < count($tmpResult); $i++) { foreach ($tmpResult[$i] as $field => $value) { if (!is_numeric($field)) { $arResult[$i][$field] = $value; } } } if (!empty($arResult)) { if ($showSql) { $arResult['SQL'] = $res->getSql(); } return $arResult; } else { return false; } } else { if ($showSql) { $arResult['SQL'] = $res->getSql(); return $arResult; } else { return false; } } }