本文整理汇总了PHP中Bitrix\Main\Type\Collection::isAssociative方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::isAssociative方法的具体用法?PHP Collection::isAssociative怎么用?PHP Collection::isAssociative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Type\Collection
的用法示例。
在下文中一共展示了Collection::isAssociative方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Set
public static function Set($messageId, $params = array())
{
$messageId = intval($messageId);
if (!(is_array($params) || is_null($params)) || $messageId <= 0) {
return false;
}
if (is_null($params) || count($params) <= 0) {
return self::DeleteAll($messageId);
}
$default = self::GetDefault();
$arToDelete = array();
foreach ($params as $key => $val) {
if (isset($default[$key]) && $default[$key] == $val) {
$arToDelete[$key] = array("=MESSAGE_ID" => $messageId, "=PARAM_NAME" => $key);
}
}
$arToInsert = array();
foreach ($params as $k1 => $v1) {
$name = substr(trim($k1), 0, 100);
if (strlen($name)) {
if (is_object($v1) && $v1 instanceof CIMMessageParamAttach) {
$v1 = array($v1);
} else {
if (is_array($v1) && \Bitrix\Main\Type\Collection::isAssociative($v1)) {
$v1 = array($v1);
} else {
if (!is_array($v1)) {
$v1 = array($v1);
}
}
}
if (empty($v1)) {
$arToDelete[$name] = array("=MESSAGE_ID" => $messageId, "=PARAM_NAME" => $name);
} else {
foreach ($v1 as $v2) {
if (is_array($v2)) {
$value = \Bitrix\Main\Web\Json::encode($v2);
if (strlen($value)) {
$key = md5($name . $value);
$arToInsert[$key] = array("MESSAGE_ID" => $messageId, "PARAM_NAME" => $name, "PARAM_VALUE" => isset($v2['ID']) ? $v2['ID'] : time(), "PARAM_JSON" => $value);
}
} else {
if (is_object($v2) && $v2 instanceof CIMMessageParamAttach) {
$value = $v2->GetJSON();
$valueArray = $v2->GetArray();
if (strlen($value)) {
$key = md5($name . $value);
$arToInsert[$key] = array("MESSAGE_ID" => $messageId, "PARAM_NAME" => $name, "PARAM_VALUE" => $valueArray['ID'], "PARAM_JSON" => $value);
}
} else {
$value = substr(trim($v2), 0, 100);
if (strlen($value)) {
$key = md5($name . $value);
$arToInsert[$key] = array("MESSAGE_ID" => $messageId, "PARAM_NAME" => $name, "PARAM_VALUE" => $value);
}
}
}
}
}
}
}
if (!empty($arToInsert)) {
$messageParameters = IM\MessageParamTable::getList(array('select' => array('ID', 'PARAM_NAME', 'PARAM_VALUE', 'PARAM_JSON'), 'filter' => array('=MESSAGE_ID' => $messageId)));
while ($ar = $messageParameters->fetch()) {
if (strlen($ar['PARAM_JSON'])) {
$key = md5($ar["PARAM_NAME"] . $ar["PARAM_JSON"]);
} else {
$key = md5($ar["PARAM_NAME"] . $ar["PARAM_VALUE"]);
}
if (array_key_exists($key, $arToInsert)) {
unset($arToInsert[$key]);
} else {
if (isset($params[$ar["PARAM_NAME"]])) {
IM\MessageParamTable::delete($ar['ID']);
}
}
}
}
foreach ($arToInsert as $parameterInfo) {
IM\MessageParamTable::add($parameterInfo);
}
foreach ($arToDelete as $filter) {
$messageParameters = IM\MessageParamTable::getList(array('select' => array('ID'), 'filter' => $filter));
while ($parameterInfo = $messageParameters->fetch()) {
IM\MessageParamTable::delete($parameterInfo['ID']);
}
}
return true;
}