예제 #1
0
 public static function Delete($lang)
 {
     global $DB;
     $DB->Query("SELECT * FROM `" . self::$table . "` WHERE `SID` = '" . sSql($lang) . "'");
     if (!$DB->numRows()) {
         return false;
     } else {
         $sql = "DELETE FROM `" . self::$table . "` WHERE `SID` = '" . sSql($lang) . "';";
         if ($DB->Query($sql)) {
             return true;
         } else {
             dbError($DB->Error());
             return false;
         }
     }
 }
예제 #2
0
 public static function Delete($ID)
 {
     global $DB;
     $DB->Query("SELECT * FROM `" . self::$table . "` WHERE `ID` = '" . sSql($ID) . "'");
     if (!$DB->numRows()) {
         return false;
     } else {
         $sql1 = "DELETE FROM `" . self::$table . "` WHERE `ID` = '" . sSql($ID) . "';";
         $sql2 = "DELETE FROM `" . self::$table_lang . "` WHERE `CATALOG_TYPE_ID` = '" . sSql($ID) . "';";
         if ($DB->Query($sql1) and $DB->Query($sql2)) {
             return true;
         } else {
             dbError($DB->Error());
             return false;
         }
     }
 }
예제 #3
0
 /**
  * Получить ID св-ва по его CODE
  * @param string $CODE
  */
 public static function GetPropIDByCODE($CODE)
 {
     global $DB;
     $DB->Query("SELECT `ID` FROM `" . self::$table . "` WHERE `CODE` = '" . sSql($CODE) . "'");
     if ($arResult = $DB->Fetch()) {
         return $arResult["ID"];
     }
 }
예제 #4
0
/**
 * Склеить из массива SQL-выражение для фильтра
 * @param array $arFilter
 * @param array $arTables
 * @return string
 */
function filterGlue($arFilter, $arTables = false)
{
    //d($arFilter);
    $cnt = 0;
    $str = '';
    $signs = array('=', '!', '!=', '<', '>', '<=', '>=');
    if (is_array($arFilter['CATALOG_ID']) and !empty($arFilter['CATALOG_ID'])) {
        $arCatalogIDs = $arFilter['CATALOG_ID'];
        unset($arFilter['CATALOG_ID']);
    }
    foreach ($arFilter as $key => $value) {
        if ($value == "" and !in_array($key, $signs)) {
            unset($arFilter[$key]);
        }
    }
    foreach ($arFilter as $key => $value) {
        $cnt++;
        $sign = getSign($key);
        $key = str_replace($signs, '', $key);
        $arConstants = array("NULL", "null", "FALSE", "false", "TRUE", "true");
        if ($value === "NULL" or $value === "null") {
            switch ($sign) {
                case '=':
                    $sign = 'IS';
                    break;
                case '!=':
                    $sign = 'IS NOT';
                    break;
                default:
                    $sign = $sign;
                    break;
            }
        }
        $bTbl = false;
        if ($arTables and is_array($arTables)) {
            foreach ($arTables as $t => $v) {
                if (strstr($value, $t . '.')) {
                    $bTbl = true;
                }
            }
        }
        if ($arTables and $bTbl or in_array($value, $arConstants)) {
            $str .= sSql($key) . " " . $sign . " " . sSql($value);
        } else {
            $str .= sSql($key) . " " . $sign . " '" . sSql($value) . "'";
        }
        if ($cnt != count($arFilter)) {
            $str .= " AND ";
        }
    }
    if (is_array($arCatalogIDs) and !empty($arCatalogIDs)) {
        if (!empty($str)) {
            $str .= " AND";
        }
        $str .= " (";
        $cntr = 1;
        foreach ($arCatalogIDs as $catID) {
            if ($arTables === false) {
                $str .= "CATALOG_ID = '" . intVal($catID) . "'";
            } else {
                $str .= "ELEMENT.CATALOG_ID = '" . intVal($catID) . "'";
            }
            if ($cntr != count($arCatalogIDs)) {
                $str .= " OR ";
                $cntr++;
            }
        }
        $str .= ') GROUP BY ';
        if ($arTables === false) {
            $str .= "ID";
        } else {
            $str .= "ELEMENT.ID";
        }
    }
    return $str;
}
예제 #5
0
 /**
  * Получить массив с данными пользователя по его логину
  * @global object $DB
  * @param string $login
  * @param bool $bWOGroups без получения групп
  * @return array
  */
 public static function GetByLogin($login, $bWOGroups = false)
 {
     $DB = App::DB();
     $sql = "SELECT * FROM `b_user` WHERE `LOGIN` = '" . sSql($login) . "';";
     $DB->Query($sql);
     if ($arUser = $DB->Fetch()) {
         if (!$bWOGroups) {
             $sql = "SELECT * FROM `b_user_group` WHERE `USER_ID` = '" . $arUser["ID"] . "';";
             $DB->Query($sql);
             while ($arGroup = $DB->Fetch()) {
                 $arUser["GROUPS"][] = $arGroup["GROUP_ID"];
             }
             return $arUser;
         } else {
             return $arUser;
         }
     }
     return false;
 }
예제 #6
0
 private static function updatePropertyEnum($ID, $arValue)
 {
     global $DB;
     $sql = "UPDATE " . self::$table_props_enum . " SET " . "`TIMESTAMP_X` = '" . date("Y-m-d H:i:s") . "', " . "`VALUE` = '" . sXss(sSql($arValue["VALUE"])) . "', " . "`SORT` = '" . (!empty($arValue["SORT"]) ? intVal($arValue["SORT"]) : '500') . "', " . "`XML_ID` = '" . (!empty($arValue["XML_ID"]) ? sXss(sSql($arValue["XML_ID"])) : '') . "', " . "`DEF` = '" . ($arValue["DEF"] == "N" ? 'N' : 'Y') . "' " . "WHERE `PROPERTY_ID` = '" . intVal($ID) . "';";
     $DB->Query($sql);
     return true;
 }