本文整理汇总了PHP中CIBlock::ForLIKE方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::ForLIKE方法的具体用法?PHP CIBlock::ForLIKE怎么用?PHP CIBlock::ForLIKE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::ForLIKE方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FilterCreateEx
public static function FilterCreateEx($fname, $vals, $type, &$bFullJoin, $cOperationType = false, $bSkipEmpty = true)
{
/** @global CDatabase $DB */
global $DB;
if (!is_array($vals)) {
$vals = array($vals);
}
if (count($vals) < 1) {
return "";
}
if (is_bool($cOperationType)) {
if ($cOperationType === true) {
$cOperationType = "N";
} else {
$cOperationType = "E";
}
}
if ($cOperationType == "E") {
// most req operation
$strOperation = "=";
} elseif ($cOperationType == "G") {
$strOperation = ">";
} elseif ($cOperationType == "GE") {
$strOperation = ">=";
} elseif ($cOperationType == "LE") {
$strOperation = "<=";
} elseif ($cOperationType == "L") {
$strOperation = "<";
} elseif ($cOperationType == 'B') {
$strOperation = array('BETWEEN', 'AND');
} elseif ($cOperationType == 'NB') {
$strOperation = array('BETWEEN', 'AND');
} else {
$strOperation = "=";
}
if ($cOperationType == 'B' || $cOperationType == 'NB') {
if (count($vals) == 2 && !is_array($vals[0])) {
$vals = array($vals);
}
}
$bNegative = substr($cOperationType, 0, 1) == "N";
$bFullJoin = false;
$bWasLeftJoin = false;
$arIn = array();
//This will gather equality number conditions
$bWasNull = false;
$res = array();
foreach ($vals as $val) {
if (!$bSkipEmpty || is_array($strOperation) && is_array($val) || is_bool($val) && $val === false || strlen($val) > 0) {
switch ($type) {
case "string_equal":
if ($cOperationType == "?") {
if (strlen($val) > 0) {
$res[] = GetFilterQuery($fname, $val, "N");
}
} elseif ($cOperationType == "S" || $cOperationType == "NS") {
$res[] = ($cOperationType == "NS" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . CIBlock::_Upper($fname) . " LIKE " . CIBlock::_Upper("'%" . CIBlock::ForLIKE($val) . "%'") . ")";
} elseif (($cOperationType == "B" || $cOperationType == "NB") && is_array($val) && count($val) == 2) {
$res[] = ($cOperationType == "NB" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . CIBlock::_Upper($fname) . " " . $strOperation[0] . " '" . CIBlock::_Upper($DB->ForSql($val[0])) . "' " . $strOperation[1] . " '" . CIBlock::_Upper($DB->ForSql($val[1])) . "')";
} else {
if (strlen($val) <= 0) {
$res[] = ($cOperationType == "N" ? "NOT" : "") . "(" . $fname . " IS NULL OR " . $DB->Length($fname) . "<=0)";
} else {
$res[] = ($cOperationType == "N" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . CIBlock::_Upper($fname) . $strOperation . CIBlock::_Upper("'" . $DB->ForSql($val) . "'") . ")";
}
}
break;
case "string":
if ($cOperationType == "?") {
if (strlen($val) > 0) {
$sr = GetFilterQuery($fname, $val, "Y", array(), $fname == "BE.SEARCHABLE_CONTENT" || $fname == "BE.DETAIL_TEXT" ? "Y" : "N");
if ($sr != "0") {
$res[] = $sr;
}
}
} elseif (($cOperationType == "B" || $cOperationType == "NB") && is_array($val) && count($val) == 2) {
$res[] = ($cOperationType == "NB" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . CIBlock::_Upper($fname) . " " . $strOperation[0] . " '" . CIBlock::_Upper($DB->ForSql($val[0])) . "' " . $strOperation[1] . " '" . CIBlock::_Upper($DB->ForSql($val[1])) . "')";
} elseif ($cOperationType == "S" || $cOperationType == "NS") {
$res[] = ($cOperationType == "NS" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . CIBlock::_Upper($fname) . " LIKE " . CIBlock::_Upper("'%" . CIBlock::ForLIKE($val) . "%'") . ")";
} else {
if (strlen($val) <= 0) {
$res[] = ($bNegative ? "NOT" : "") . "(" . $fname . " IS NULL OR " . $DB->Length($fname) . "<=0)";
} else {
if ($strOperation == "=" && $cOperationType != "I" && $cOperationType != "NI") {
$res[] = ($cOperationType == "N" ? " " . $fname . " IS NULL OR NOT " : "") . "(" . ($DB->type == "ORACLE" ? CIBlock::_Upper($fname) . " LIKE " . CIBlock::_Upper("'" . $DB->ForSqlLike($val) . "'") . " ESCAPE '\\'" : $fname . " LIKE '" . $DB->ForSqlLike($val) . "'") . ")";
} else {
$res[] = ($bNegative ? " " . $fname . " IS NULL OR NOT " : "") . "(" . ($DB->type == "ORACLE" ? CIBlock::_Upper($fname) . " " . $strOperation . " " . CIBlock::_Upper("'" . $DB->ForSql($val) . "'") . " " : $fname . " " . $strOperation . " '" . $DB->ForSql($val) . "'") . ")";
}
}
}
break;
case "date":
if (!is_array($val) && strlen($val) <= 0) {
$res[] = ($cOperationType == "N" ? "NOT" : "") . "(" . $fname . " IS NULL)";
} elseif (($cOperationType == "B" || $cOperationType == "NB") && is_array($val) && count($val) == 2) {
$res[] = ($cOperationType == 'NB' ? ' ' . $fname . ' IS NULL OR NOT ' : '') . '(' . $fname . ' ' . $strOperation[0] . ' ' . $DB->CharToDateFunction($DB->ForSql($val[0]), "FULL") . ' ' . $strOperation[1] . ' ' . $DB->CharToDateFunction($DB->ForSql($val[1]), "FULL") . ')';
} else {
$res[] = ($bNegative ? " " . $fname . " IS NULL OR NOT " : "") . "(" . $fname . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")";
}
break;
//.........这里部分代码省略.........