function GetIDByName($name) { $err_mess = CAllOperation::err_mess() . "<br>Function: GetIDByName<br>Line: "; $z = COperation::GetList(array('MODULE_ID' => 'asc'), array("NAME" => $name)); if ($r = $z->Fetch()) { return $r['ID']; } return false; }
function GetList($arOrder = array('MODULE_ID' => 'asc'), $arFilter = array()) { global $DB; static $arFields = array("ID" => array("FIELD_NAME" => "O.ID", "FIELD_TYPE" => "int"), "NAME" => array("FIELD_NAME" => "O.NAME", "FIELD_TYPE" => "string"), "MODULE_ID" => array("FIELD_NAME" => "O.MODULE_ID", "FIELD_TYPE" => "string"), "BINDING" => array("FIELD_NAME" => "O.BINDING", "FIELD_TYPE" => "string")); $err_mess = CAllOperation::err_mess() . "<br>Function: GetList<br>Line: "; $arSqlSearch = array(); if (is_array($arFilter)) { foreach ($arFilter as $n => $val) { $n = strtoupper($n); if ($val == '' || strval($val) == "NOT_REF") { continue; } if ($n == 'ID' || $n == 'MODULE_ID' || $n == 'BINDING') { $arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val, 'N'); } elseif (isset($arFields[$n])) { $arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val); } } } $strOrderBy = ''; foreach ($arOrder as $by => $order) { if (isset($arFields[strtoupper($by)])) { $strOrderBy .= $arFields[strtoupper($by)]["FIELD_NAME"] . ' ' . (strtolower($order) == 'desc' ? 'desc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS LAST" : "") : 'asc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS FIRST" : "")) . ','; } } if ($strOrderBy != '') { $strOrderBy = "ORDER BY " . rtrim($strOrderBy, ","); } $strSqlSearch = GetFilterSqlSearch($arSqlSearch); $strSql = "\n\t\t\tSELECT *\n\t\t\tFROM\n\t\t\t\tb_operation O\n\t\t\tWHERE\n\t\t\t\t" . $strSqlSearch . "\n\t\t\t" . $strOrderBy; $res = $DB->Query($strSql, false, $err_mess . __LINE__); return $res; }