本文整理汇总了PHP中CIBlock::roundDB方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::roundDB方法的具体用法?PHP CIBlock::roundDB怎么用?PHP CIBlock::roundDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::roundDB方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NextStep21
function NextStep21($arIBlock)
{
global $DB, $_SESSION, $arErrors, $arMessages, $INTERVAL;
$strSql = "\n\t\tSELECT *\n\t\tFROM b_iblock_element_prop_s" . $arIBlock["ID"] . "\n\t";
$rsElement = $DB->Query($strSql);
$t = getmicrotime();
$i = 0;
while ($arElement = $rsElement->Fetch()) {
$ELEMENT_ID = $arElement["IBLOCK_ELEMENT_ID"];
foreach ($arElement as $key => $value) {
if (substr($key, 0, 9) == "PROPERTY_" && strlen($value) > 0) {
$ID = intval(substr($key, 9));
//TODO make conversion and check forsql and bind!!!!
if ($ID > 0 && array_key_exists($ID, $_SESSION["BX_IBLOCK_CONV"]["arSingle"])) {
$arFields = array("IBLOCK_ELEMENT_ID" => $ELEMENT_ID, "IBLOCK_PROPERTY_ID" => $ID, "VALUE" => $value, "~VALUE_NUM" => CIBlock::roundDB($value), "~VALUE_ENUM" => intval($value), "DESCRIPTION" => $arElement["DESCRIPTION_" . $ID]);
$arInsert = $DB->PrepareInsert("b_iblock_element_property", $arFields);
$rs = $DB->QueryBind("INSERT INTO b_iblock_element_property (" . $arInsert[0] . ")VALUES(" . $arInsert[1] . ")", array("DESCRIPTION" => $arElement["DESCRIPTION_" . $ID]));
}
}
}
$strSql = "\n\t\t\tINSERT INTO b_iblock_element_property\n\t\t\t(IBLOCK_ELEMENT_ID,IBLOCK_PROPERTY_ID,VALUE,VALUE_ENUM,VALUE_NUM,DESCRIPTION)\n\t\t\tSELECT IBLOCK_ELEMENT_ID,IBLOCK_PROPERTY_ID,VALUE,VALUE_ENUM,VALUE_NUM,DESCRIPTION\n\t\t\tFROM b_iblock_element_prop_m" . $arIBlock["ID"] . "\n\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t";
$rs = $DB->Query($strSql);
$strSql = "\n\t\t\tDELETE\n\t\t\tFROM b_iblock_element_prop_m" . $arIBlock["ID"] . "\n\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t";
$rs = $DB->Query($strSql);
$strSql = "\n\t\t\tDELETE\n\t\t\tFROM b_iblock_element_prop_s" . $arIBlock["ID"] . "\n\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t";
$rs = $DB->Query($strSql);
$DB->Query("UPDATE b_iblock SET LAST_CONV_ELEMENT = " . $ELEMENT_ID . " WHERE ID = " . $arIBlock["ID"]);
$i++;
if (getmicrotime() - $t > $INTERVAL) {
break;
}
}
$_SESSION["BX_IBLOCK_CONV"]["DONE"] += $i;
if ($_SESSION["BX_IBLOCK_CONV"]["TODO"] < $_SESSION["BX_IBLOCK_CONV"]["DONE"]) {
$_SESSION["BX_IBLOCK_CONV"]["TODO"] = $_SESSION["BX_IBLOCK_CONV"]["DONE"];
}
//$_SESSION["BX_IBLOCK_CONV"]["STAT"][]=$i;$arMessages[]=implode(', ',$_SESSION["BX_IBLOCK_CONV"]["STAT"]);
if ($arElement) {
return 3;
} else {
return 4;
}
}
示例2: SetPropertyValues
//.........这里部分代码省略.........
$arV = $cacheValues[$prop["ID"]];
}
$arWas = array();
foreach ($arV as $res) {
$val = $PROP[$res["ID"]];
if (is_array($val) && !is_set($val, "tmp_name") && !is_set($val, "del")) {
$val_desc = $val["DESCRIPTION"];
$val = $val["VALUE"];
} else {
$val_desc = false;
}
if ($prop["PROPERTY_TYPE"] == "E") {
if (in_array($val, $arWas)) {
$val = "";
} else {
$arWas[] = $val;
}
}
if ($prop["PROPERTY_TYPE"] == "S" || $prop["PROPERTY_TYPE"] == "N" || $prop["PROPERTY_TYPE"] == "E") {
if (strlen($val) <= 0) {
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
$strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tPROPERTY_" . $prop["ID"] . "=null\n\t\t\t\t\t\t\t\t\t\t,DESCRIPTION_" . $prop["ID"] . "=null\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID;
} else {
$strSql = "DELETE FROM " . $strTable . " WHERE ID=" . $res["ID"];
}
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
$strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $prop["ID"] . "=NULL, DESCRIPTION_" . $prop["ID"] . "=NULL\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
} else {
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
if ($prop["PROPERTY_TYPE"] == "N") {
$val = CIBlock::roundDB($val);
}
$strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . "='" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t,DESCRIPTION_" . $prop["ID"] . "=" . ($val_desc !== false ? "'" . $DB->ForSQL($val_desc, 255) . "'" : "null") . "\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID;
} else {
$strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE " . $strTable . "\n\t\t\t\t\t\t\t\t\tSET \tVALUE='" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t\t,VALUE_NUM=" . CIBlock::roundDB($val) . "\n\t\t\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ",DESCRIPTION='" . $DB->ForSql($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\t\t\tWHERE ID=" . $res["ID"];
}
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
$strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $prop["ID"] . "=NULL, DESCRIPTION_" . $prop["ID"] . "=NULL\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
} elseif ($prop["PROPERTY_TYPE"] == "F") {
if (is_array($val)) {
if (strlen($val["del"]) > 0) {
$val = "NULL";
} else {
$val["MODULE_ID"] = "iblock";
if ($val_desc !== false) {
$val["description"] = $val_desc;
}
if ($val_desc !== false && strlen($val["name"]) <= 0) {
//update description only
if ($res["VALUE"] > 0) {
CFile::UpdateDesc($res["VALUE"], $val_desc);
}
$val = false;
} else {
//register new file
$val = CFile::SaveFile($val, "iblock");
}
}
}
示例3: SetPropertyValues
//.........这里部分代码省略.........
} else {
$DB->Query("\n\t\t\t\t\t\tINSERT INTO " . $strTable . "\n\t\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM)\n\t\t\t\t\t\tSELECT " . $ELEMENT_ID . ", P.ID, S.ID, S.ID\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t\t,b_iblock_section S\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tP.ID=" . $prop["ID"] . "\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\tP.LINK_IBLOCK_ID IS NULL\n\t\t\t\t\t\t\t\tOR P.LINK_IBLOCK_ID = 0\n\t\t\t\t\t\t\t\tOR S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tAND S.ID IN (" . $ids . ")\n\t\t\t\t\t");
}
$DB->Query("\n\t\t\t\t\tINSERT INTO b_iblock_section_element\n\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_SECTION_ID, ADDITIONAL_PROPERTY_ID)\n\t\t\t\t\tSELECT " . $ELEMENT_ID . ", S.ID, P.ID\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t,b_iblock_section S\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tP.ID = " . $prop["ID"] . "\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\tP.LINK_IBLOCK_ID IS NULL\n\t\t\t\t\t\t\tOR P.LINK_IBLOCK_ID = 0\n\t\t\t\t\t\t\tOR S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND S.ID IN (" . $ids . ")\n\t\t\t\t");
} elseif ($prop["PROPERTY_TYPE"] == "E") {
$arWas = array();
if ($arDBProps[$prop["ID"]]) {
foreach ($arDBProps[$prop["ID"]] as $res) {
$val = $PROP[$res["ID"]];
if (is_array($val)) {
$val_desc = $val["DESCRIPTION"];
$val = $val["VALUE"];
} else {
$val_desc = false;
}
if (isset($arWas[$val])) {
$val = "";
} else {
$arWas[$val] = true;
}
if (strlen($val) <= 0) {
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
$DB->Query($s = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . " = null\n\t\t\t\t\t\t\t\t\t" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"]) . "\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t");
} else {
$DB->Query($s = "\n\t\t\t\t\t\t\t\t\tDELETE FROM " . $strTable . "\n\t\t\t\t\t\t\t\t\tWHERE ID=" . $res["ID"] . "\n\t\t\t\t\t\t\t\t");
}
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
$arV2ClearCache[$prop["ID"]] = "PROPERTY_" . $prop["ID"] . " = NULL" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"]);
}
} elseif ($res["VALUE"] !== $val || $res["DESCRIPTION"] . '' !== $val_desc . '') {
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
$DB->Query("\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . " = '" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"], $val_desc) . "\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t");
} else {
$DB->Query("\n\t\t\t\t\t\t\t\t\tUPDATE " . $strTable . "\n\t\t\t\t\t\t\t\t\tSET VALUE = '" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t\t,VALUE_NUM = " . CIBlock::roundDB($val) . "\n\t\t\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ",DESCRIPTION = '" . $DB->ForSql($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\t\t\tWHERE ID=" . $res["ID"] . "\n\t\t\t\t\t\t\t\t");
}
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
$arV2ClearCache[$prop["ID"]] = "PROPERTY_" . $prop["ID"] . " = NULL" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"]);
}
}
unset($PROP[$res["ID"]]);
}
//foreach($arDBProps[$prop["ID"]] as $res)
}
foreach ($PROP as $val) {
if (is_array($val)) {
$val_desc = $val["DESCRIPTION"];
$val = $val["VALUE"];
} else {
$val_desc = false;
}
if (isset($arWas[$val])) {
$val = "";
} else {
$arWas[$val] = true;
}
if (strlen($val) <= 0) {
continue;
}
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
$DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\tPROPERTY_" . $prop["ID"] . " = '" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"], $val_desc) . "\n\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t");
} else {
$DB->Query("\n\t\t\t\t\t\t\tINSERT INTO " . $strTable . "\n\t\t\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM" . ($val_desc !== false ? ", DESCRIPTION" : "") . ")\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t,P.ID\n\t\t\t\t\t\t\t\t,'" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t," . CIBlock::roundDB($val) . "\n\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ", '" . $DB->ForSQL($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tID = " . IntVal($prop["ID"]) . "\n\t\t\t\t\t\t");
}
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
$arV2ClearCache[$prop["ID"]] = "PROPERTY_" . $prop["ID"] . " = NULL" . self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"]);
}
示例4: SetPropertyValuesEx
//.........这里部分代码省略.........
foreach ($values as $value) {
$value["VALUE"] = intval($value["VALUE"]);
if ($value["VALUE"] > 0) {
$arID[] = $value["VALUE"];
}
}
if (count($arID) > 0) {
if ($db_prop["VERSION"] == 1) {
$ar2Insert["sqls"]["b_iblock_element_property"][$property_id] = "\n\t\t\t\t\t\t\t\tINSERT INTO b_iblock_element_property\n\t\t\t\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM)\n\t\t\t\t\t\t\t\tSELECT " . $ELEMENT_ID . ", P.ID, S.ID, S.ID\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t\t\t\t,b_iblock_section S\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tP.ID=" . $property_id . "\n\t\t\t\t\t\t\t\t\tAND S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t\t\t\tAND S.ID IN (" . implode(", ", $arID) . ")\n\t\t\t\t\t\t";
} elseif ($db_prop["MULTIPLE"] == "Y") {
$ar2Insert["sqls"]["b_iblock_element_prop_m" . $IBLOCK_ID][$property_id] = "\n\t\t\t\t\t\t\t\tINSERT INTO b_iblock_element_prop_m" . $IBLOCK_ID . "\n\t\t\t\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM)\n\t\t\t\t\t\t\t\tSELECT " . $ELEMENT_ID . ", P.ID, S.ID, S.ID\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t\t\t\t,b_iblock_section S\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tP.ID=" . $property_id . "\n\t\t\t\t\t\t\t\t\tAND S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t\t\t\tAND S.ID IN (" . implode(", ", $arID) . ")\n\t\t\t\t\t\t";
$ar2Update["b_iblock_element_prop_s" . $IBLOCK_ID][$property_id] = false;
//null
} else {
$rs = $DB->Query("\n\t\t\t\t\t\t\t\tSELECT S.ID\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_iblock_property P\n\t\t\t\t\t\t\t\t\t,b_iblock_section S\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tP.ID=" . $property_id . "\n\t\t\t\t\t\t\t\t\tAND S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t\t\t\tAND S.ID IN (" . implode(", ", $arID) . ")\n\t\t\t\t\t\t");
if ($ar = $rs->Fetch()) {
$ar2Update["b_iblock_element_prop_s" . $IBLOCK_ID][$property_id] = array("VALUE" => $ar["ID"], "DESCRIPTION" => "");
}
}
$ar2Insert["sqls"]["b_iblock_section_element"][$property_id] = "\n\t\t\t\t\t\tINSERT INTO b_iblock_section_element\n\t\t\t\t\t\t(IBLOCK_ELEMENT_ID, IBLOCK_SECTION_ID, ADDITIONAL_PROPERTY_ID)\n\t\t\t\t\t\tSELECT " . $ELEMENT_ID . ", S.ID, P.ID\n\t\t\t\t\t\tFROM b_iblock_property P, b_iblock_section S\n\t\t\t\t\t\tWHERE P.ID=" . $property_id . "\n\t\t\t\t\t\t\tAND S.IBLOCK_ID = P.LINK_IBLOCK_ID\n\t\t\t\t\t\t\tAND S.ID IN (" . implode(", ", $arID) . ")\n\t\t\t\t\t";
}
continue;
}
foreach ($values as $value) {
if ($db_prop["VERSION"] == 1) {
$ar2Insert["values"]["b_iblock_element_property"][$property_id][] = $value;
} elseif ($db_prop["MULTIPLE"] == "Y") {
$ar2Insert["values"]["b_iblock_element_prop_m" . $IBLOCK_ID][$property_id][] = $value;
$ar2Update["b_iblock_element_prop_s" . $IBLOCK_ID][$property_id] = false;
//null
} else {
$ar2Update["b_iblock_element_prop_s" . $IBLOCK_ID][$property_id] = $value;
}
}
}
foreach ($ar2Delete as $table => $arID) {
if (count($arID) > 0) {
if ($table == "b_iblock_section_element") {
$DB->Query("\n\t\t\t\t\t\tdelete from " . $table . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\tand ADDITIONAL_PROPERTY_ID in (" . implode(", ", array_keys($arID)) . ")\n\t\t\t\t\t");
} else {
$DB->Query("\n\t\t\t\t\t\tdelete from " . $table . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\tand IBLOCK_PROPERTY_ID in (" . implode(", ", array_keys($arID)) . ")\n\t\t\t\t\t");
}
}
}
foreach ($ar2Insert["values"] as $table => $properties) {
$strSqlPrefix = "\n\t\t\t\t\tinsert into " . $table . "\n\t\t\t\t\t(IBLOCK_PROPERTY_ID, IBLOCK_ELEMENT_ID, VALUE, VALUE_ENUM, VALUE_NUM, DESCRIPTION)\n\t\t\t\t\tvalues\n\t\t\t";
$maxValuesLen = $DB->type == "MYSQL" ? 1024 : 0;
$strSqlValues = "";
foreach ($properties as $property_id => $values) {
foreach ($values as $value) {
if (strlen($value["VALUE"]) > 0) {
$strSqlValues .= ",\n(" . $property_id . ", " . $ELEMENT_ID . ", " . "'" . $DB->ForSQL($value["VALUE"]) . "', " . intval($value["VALUE"]) . ", " . CIBlock::roundDB($value["VALUE"]) . ", " . (strlen($value["DESCRIPTION"]) ? "'" . $DB->ForSQL($value["DESCRIPTION"]) . "'" : "null") . " " . ")";
}
if (strlen($strSqlValues) > $maxValuesLen) {
$DB->Query($strSqlPrefix . substr($strSqlValues, 2));
$strSqlValues = "";
}
}
}
if (strlen($strSqlValues) > 0) {
$DB->Query($strSqlPrefix . substr($strSqlValues, 2));
$strSqlValues = "";
}
}
foreach ($ar2Insert["sqls"] as $table => $properties) {
foreach ($properties as $property_id => $sql) {
$DB->Query($sql);
}
}
foreach ($ar2Update as $table => $properties) {
$tableFields = $DB->GetTableFields($table);
if (count($properties) > 0) {
$arFields = array();
foreach ($properties as $property_id => $value) {
if ($value === false || strlen($value["VALUE"]) <= 0) {
$arFields[] = "PROPERTY_" . $property_id . " = null";
if (isset($tableFields["DESCRIPTION_" . $property_id])) {
$arFields[] = "DESCRIPTION_" . $property_id . " = null";
}
} else {
$arFields[] = "PROPERTY_" . $property_id . " = '" . $DB->ForSQL($value["VALUE"]) . "'";
if (isset($tableFields["DESCRIPTION_" . $property_id])) {
if (strlen($value["DESCRIPTION"])) {
$arFields[] = "DESCRIPTION_" . $property_id . " = '" . $DB->ForSQL($value["DESCRIPTION"]) . "'";
} else {
$arFields[] = "DESCRIPTION_" . $property_id . " = null";
}
}
}
}
$DB->Query("\n\t\t\t\t\tupdate " . $table . "\n\t\t\t\t\tset " . implode(",\n", $arFields) . "\n\t\t\t\t\twhere IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t");
}
}
/****************************** QUOTA ******************************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
/****************************** QUOTA ******************************/
foreach (GetModuleEvents("iblock", "OnAfterIBlockElementSetPropertyValuesEx", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUES, $FLAGS));
}
}
示例5: SetPropertyValues
//.........这里部分代码省略.........
if (isset($arWas[$val]))
$val = "";
else
$arWas[$val] = true;
if (strlen($val) <= 0) //Delete property value
{
$DB->Query(CIBLockElement::DeletePropertySQL($prop, $ELEMENT_ID));
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y")
{
$arV2ClearCache[$prop["ID"]] =
"PROPERTY_".$prop["ID"]." = NULL"
.self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"])
;
}
}
elseif ($res["VALUE"] !== $val) //Update property value
{
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N")
{
$DB->Query("
UPDATE b_iblock_element_prop_s".$prop["IBLOCK_ID"]."
SET PROPERTY_".$prop["ID"]." = '".$DB->ForSql($val)."'
".self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"], $val_desc)."
WHERE IBLOCK_ELEMENT_ID = ".$ELEMENT_ID."
");
}
else
{
$DB->Query("
UPDATE ".$strTable."
SET VALUE = '".$DB->ForSql($val)."'
,VALUE_NUM = ".CIBlock::roundDB($val)."
".($val_desc!==false ? ",DESCRIPTION = '".$DB->ForSql($val_desc, 255)."'" : "")."
WHERE ID=".$res["ID"]."
");
}
if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y")
{
$arV2ClearCache[$prop["ID"]] =
"PROPERTY_".$prop["ID"]." = NULL"
.self::__GetDescriptionUpdateSql($prop["IBLOCK_ID"], $prop["ID"])
;
}
}
unset($PROP[$res["ID"]]);
} //foreach($arDBProps[$prop["ID"]] as $res)
}
foreach ($PROP as $val)
{
if (is_array($val))
{
$val_desc = $val["DESCRIPTION"];
$val = $val["VALUE"];
}
else
{
$val_desc = false;
}
if (isset($arWas[$val]))
$val = "";