- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/classes/general/forum_new.php
- Класс: CAllForumNew
- Вызов: CAllForumNew::prepareField
static function prepareField($operation, $type, $vals)
{
$val = '';
if ($operation == "IN")
{
if (is_string($vals))
$vals = explode(",", $vals);
else if (!is_array($vals))
$vals = array($vals);
if ($type == "int")
{
array_walk(
$vals,
function (&$item) {
$item = (int)$item;
}
);
$vals = array_unique($vals);
$val = implode(",", $vals);
}
elseif ($type == "double")
{
array_walk(
$vals,
function (&$item) {
$item = (float)$item;
}
);
$vals = array_unique($vals);
$val = implode(",", $vals);
}
elseif ($type == "datetime")
{
array_walk(
$vals,
function (&$item) {
$item = $GLOBALS["DB"]->CharToDateFunction($item, "FULL");
}
);
$vals = array_unique($vals);
$val = implode(",", $vals);
}
elseif ($type == "date")
{
array_walk(
$vals,
function (&$item) {
$item = $GLOBALS["DB"]->CharToDateFunction($item, "SHORT");
}
);
$vals = array_unique($vals);
$val = implode(",", $vals);
}
else
{
array_walk(
$vals,
function (&$item) {
$item = "'".$GLOBALS["DB"]->ForSql($item)."'";
}
);
$vals = array_unique($vals);
$val = implode(",", $vals);
}
}
else if ($type === "int")
{
$val = intval($vals);
$val = ($val > 0 ? $val : '');
}
elseif ($type === "double")
{
$val = doubleval(str_replace(",", ".", $vals));
$val = ($val > 0 ? $val : '');
}
elseif ($type === "datetime")
{
$val = $GLOBALS["DB"]->CharToDateFunction($vals, "FULL");
}
elseif ($type === "date")
{
$val = $GLOBALS["DB"]->CharToDateFunction($vals, "SHORT");
}
else if ($type == "string" || $type == "char")
{
$val = $GLOBALS["DB"]->ForSql($vals);
}
return $val;
}