public function getCondition(string $field, array $fieldConf): string
    {
        $type = strtolower($fieldConf['type']);
        $unsigned = $fieldConf['unsigned'];

        $integerCast = $this->getIntegerCast($unsigned);

        $condition = "(CASE $field WHEN NULL THEN NULL ELSE :$field END)";

        $typeToCast = [
            'date' => 'DATE',
            'datetime' => 'DATE',
            'time' => 'TIME',
            'smallint' => $integerCast,
            'integer' => $integerCast,
            'bigint' => $integerCast,
            'float' => 'DECIMAL',
            'decimal' => 'DECIMAL',
        ];

        // No cast required
        if (!array_key_exists($type, $typeToCast)) {
            return $condition;
        }

        return "CAST($condition AS {$typeToCast[$type]})";
    }
public function getCondition(string $field, array $fieldConf): string
    {
        $type = strtolower($fieldConf['type']);
        $unsigned = $fieldConf['unsigned'];

        $integerCast = $this->getIntegerCast($unsigned);

        $condition = "(CASE $field WHEN NULL THEN NULL ELSE :$field END)";

        $typeToCast = [
            'date' => 'DATE',
            'datetime' => 'DATE',
            'time' => 'TIME',
            'smallint' => $integerCast,
            'integer' => $integerCast,
            'bigint' => $integerCast,
            'float' => 'DECIMAL',
            'decimal' => 'DECIMAL',
        ];

        // No cast required
        if (!array_key_exists($type, $typeToCast)) {
            return $condition;
        }

        return "CAST($condition AS {$typeToCast[$type]})";
    }
public function getCondition ( string $ field , array $ fieldConf ) : string { $ type = strtolower ( $ fieldConf [ 'type' ] ) ; $ unsigned = $ fieldConf [ 'unsigned' ] ; $ integerCast = $ this -> getIntegerCast ( $ unsigned ) ; $ condition = "(CASE $field WHEN NULL THEN NULL ELSE :$field END)" ; $ typeToCast = [ 'date' => 'DATE' , 'datetime' => 'DATE' , 'time' => 'TIME' , 'smallint' => $ integerCast , 'integer' => $ integerCast , 'bigint' => $ integerCast , 'float' => 'DECIMAL' , 'decimal' => 'DECIMAL' , ] ; // No cast required if ( ! array_key_exists ( $ type , $ typeToCast ) ) { return $ condition ; } return "CAST($condition AS {$typeToCast[$type]})" ; }
Build the condition by casting the value if needed

@param  string $field
@param  array  $fieldConf Various values about the field

@return string
Build the condition by casting the value if needed