library/Haste/Database/QueryHelper.php
public static function computeCondition($strField, $strOperator, $varValue, $strTable = null)
    {
        $strOperator  = trim(strtolower($strOperator));
        $arrValues    = [];
        $strPattern   = '?';
        $blnAddQuotes = false;

        if ($strTable)
        {
            \Controller::loadDataContainer($strTable);

            $arrDca = &$GLOBALS['TL_DCA'][$strTable]['fields'][$strField];

            if (isset($arrDca['sql']) && stripos($arrDca['sql'], 'blob') !== false)
            {
                $blnAddQuotes = true;
            }
        }

        switch ($strOperator)
        {
            case static::OPERATOR_UNLIKE:
                $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%';
                break;
            case static::OPERATOR_EQUAL:
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_UNEQUAL:
            case '<>':
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_LOWER:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_GREATER:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_LOWER_EQUAL:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_GREATER_EQUAL:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_IN:
                $strPattern = '(' . implode(
                        ',',
                        array_map(
                            function ($value)
                            {
                                return '\'' . $value . '\'';
                            },
                            explode(',', $varValue)
                        )
                    ) . ')';
                break;
            case static::OPERATOR_NOT_IN:
                $strPattern = '(' . implode(
                        ',',
                        array_map(
                            function ($value)
                            {
                                return '\'' . $value . '\'';
                            },
                            explode(',', $varValue)
                        )
                    ) . ')';
                break;
            default:
                $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%';
                break;
        }

        $strOperator = static::transformVerboseOperator($strOperator);

        return ["$strField $strOperator $strPattern", $arrValues];
    }
public static function computeCondition($strField, $strOperator, $varValue, $strTable = null)
    {
        $strOperator  = trim(strtolower($strOperator));
        $arrValues    = [];
        $strPattern   = '?';
        $blnAddQuotes = false;

        if ($strTable)
        {
            \Controller::loadDataContainer($strTable);

            $arrDca = &$GLOBALS['TL_DCA'][$strTable]['fields'][$strField];

            if (isset($arrDca['sql']) && stripos($arrDca['sql'], 'blob') !== false)
            {
                $blnAddQuotes = true;
            }
        }

        switch ($strOperator)
        {
            case static::OPERATOR_UNLIKE:
                $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%';
                break;
            case static::OPERATOR_EQUAL:
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_UNEQUAL:
            case '<>':
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_LOWER:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_GREATER:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_LOWER_EQUAL:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_GREATER_EQUAL:
                $strPattern  = 'CAST(? AS DECIMAL)';
                $arrValues[] = $varValue;
                break;
            case static::OPERATOR_IN:
                $strPattern = '(' . implode(
                        ',',
                        array_map(
                            function ($value)
                            {
                                return '\'' . $value . '\'';
                            },
                            explode(',', $varValue)
                        )
                    ) . ')';
                break;
            case static::OPERATOR_NOT_IN:
                $strPattern = '(' . implode(
                        ',',
                        array_map(
                            function ($value)
                            {
                                return '\'' . $value . '\'';
                            },
                            explode(',', $varValue)
                        )
                    ) . ')';
                break;
            default:
                $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%';
                break;
        }

        $strOperator = static::transformVerboseOperator($strOperator);

        return ["$strField $strOperator $strPattern", $arrValues];
    }
public static function computeCondition ( $ strField , $ strOperator , $ varValue , $ strTable = null ) { $ strOperator = trim ( strtolower ( $ strOperator ) ) ; $ arrValues = [ ] ; $ strPattern = '?' ; $ blnAddQuotes = false ; if ( $ strTable ) { \ Controller :: loadDataContainer ( $ strTable ) ; $ arrDca = & $ GLOBALS [ 'TL_DCA' ] [ $ strTable ] [ 'fields' ] [ $ strField ] ; if ( isset ( $ arrDca [ 'sql' ] ) && stripos ( $ arrDca [ 'sql' ] , 'blob' ) !== false ) { $ blnAddQuotes = true ; } } switch ( $ strOperator ) { case static :: OPERATOR_UNLIKE : $ arrValues [ ] = '%' . ( $ blnAddQuotes ? '"' . $ varValue . '"' : $ varValue ) . '%' ; break ; case static :: OPERATOR_EQUAL : $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_UNEQUAL : case '<>' : $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_LOWER : $ strPattern = 'CAST(? AS DECIMAL)' ; $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_GREATER : $ strPattern = 'CAST(? AS DECIMAL)' ; $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_LOWER_EQUAL : $ strPattern = 'CAST(? AS DECIMAL)' ; $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_GREATER_EQUAL : $ strPattern = 'CAST(? AS DECIMAL)' ; $ arrValues [ ] = $ varValue ; break ; case static :: OPERATOR_IN : $ strPattern = '(' . implode ( ',' , array_map ( function ( $ value ) { return '\'' . $ value . '\'' ; } , explode ( ',' , $ varValue ) ) ) . ')' ; break ; case static :: OPERATOR_NOT_IN : $ strPattern = '(' . implode ( ',' , array_map ( function ( $ value ) { return '\'' . $ value . '\'' ; } , explode ( ',' , $ varValue ) ) ) . ')' ; break ; default : $ arrValues [ ] = '%' . ( $ blnAddQuotes ? '"' . $ varValue . '"' : $ varValue ) . '%' ; break ; } $ strOperator = static :: transformVerboseOperator ( $ strOperator ) ; return [ "$strField $strOperator $strPattern" , $ arrValues ] ; }
Computes a MySQL condition appropriate for the given operator

@param $strField
@param $strOperator
@param $varValue

@return array Returns array($strQuery, $arrValues)
Computes a MySQL condition appropriate for the given operator