示例#1
0
function ew_GetMultiSearchSql(&$Fld, $FldVal)
{
    $sWrk = "";
    $arVal = explode(",", $FldVal);
    foreach ($arVal as $sVal) {
        $sVal = trim($sVal);
        if (EW_IS_MYSQL) {
            $sSql = "FIND_IN_SET('" . ew_AdjustSql($sVal) . "', " . $Fld->FldExpression . ")";
        } else {
            if (count($arVal) == 1 || EW_SEARCH_MULTI_VALUE_OPTION == 3) {
                $sSql = $Fld->FldExpression . " = '" . ew_AdjustSql($sVal) . "' OR " . ew_GetMultiSearchSqlPart($Fld, $sVal);
            } else {
                $sSql = ew_GetMultiSearchSqlPart($Fld, $sVal);
            }
        }
        if ($sWrk != "") {
            if (EW_SEARCH_MULTI_VALUE_OPTION == 2) {
                $sWrk .= " AND ";
            } elseif (EW_SEARCH_MULTI_VALUE_OPTION == 3) {
                $sWrk .= " OR ";
            }
        }
        $sWrk .= "({$sSql})";
    }
    return $sWrk;
}
示例#2
0
function ew_GetMultiSearchSql(&$Fld, $FldOpr, $FldVal, $dbid)
{
    if ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
        return $Fld->FldExpression . " " . $FldOpr;
    } else {
        $sWrk = "";
        $arVal = explode(",", $FldVal);
        $dbtype = ew_GetConnectionType($dbid);
        foreach ($arVal as $sVal) {
            $sVal = trim($sVal);
            if ($sVal == EW_NULL_VALUE) {
                $sSql = $Fld->FldExpression . " IS NULL";
            } elseif ($sVal == EW_NOT_NULL_VALUE) {
                $sSql = $Fld->FldExpression . " IS NOT NULL";
            } elseif ($dbtype == "MYSQL") {
                $sSql = "FIND_IN_SET('" . ew_AdjustSql($sVal, $dbid) . "', " . $Fld->FldExpression . ")";
            } else {
                if (count($arVal) == 1 || EW_SEARCH_MULTI_VALUE_OPTION == 3) {
                    $sSql = $Fld->FldExpression . " = '" . ew_AdjustSql($sVal, $dbid) . "' OR " . ew_GetMultiSearchSqlPart($Fld, $sVal, $dbid);
                } else {
                    $sSql = ew_GetMultiSearchSqlPart($Fld, $sVal, $dbid);
                }
            }
            if ($sWrk != "") {
                if (EW_SEARCH_MULTI_VALUE_OPTION == 2) {
                    $sWrk .= " AND ";
                } elseif (EW_SEARCH_MULTI_VALUE_OPTION == 3) {
                    $sWrk .= " OR ";
                }
            }
            $sWrk .= "({$sSql})";
        }
        return $sWrk;
    }
}