public static function escapePhpExpression(array $dataTypeInfo, string $expression, bool $lobAsString): string
  {
    switch ($dataTypeInfo['data_type'])
    {
      case 'tinyint':
      case 'smallint':
      case 'mediumint':
      case 'int':
      case 'bigint':
      case 'year':
        $ret = "'.self::quoteInt(".$expression.").'";
        break;

      case 'float':
      case 'double':
        $ret = "'.self::quoteFloat(".$expression.").'";
        break;

      case 'char':
      case 'varchar':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'binary':
      case 'varbinary':
        $ret = "'.self::quoteBinary(".$expression.").'";
        break;

      case 'decimal':
        $ret = "'.self::quoteDecimal(".$expression.").'";
        break;

      case 'time':
      case 'timestamp':
      case 'date':
      case 'datetime':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'enum':
      case 'set':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'bit':
        $ret = "'.self::quoteBit(".$expression.").'";
        break;

      case 'tinytext':
      case 'text':
      case 'mediumtext':
      case 'longtext':
        $ret = ($lobAsString) ? $ret = "'.self::quoteString(".$expression.").'" : '?';
        break;

      case 'tinyblob':
      case 'blob':
      case 'mediumblob':
      case 'longblob':
        $ret = ($lobAsString) ? $ret = "'.self::quoteBinary(".$expression.").'" : '?';
        break;

      case 'list_of_int':
        $ret = "'.self::quoteListOfInt(".$expression.", '".
          addslashes($dataTypeInfo['delimiter'])."', '".
          addslashes($dataTypeInfo['enclosure'])."', '".
          addslashes($dataTypeInfo['escape'])."').'";
        break;

      default:
        throw new FallenException('data type', $dataTypeInfo['data_type']);
    }

    return $ret;
  }
public static function escapePhpExpression(array $dataTypeInfo, string $expression, bool $lobAsString): string
  {
    switch ($dataTypeInfo['data_type'])
    {
      case 'tinyint':
      case 'smallint':
      case 'mediumint':
      case 'int':
      case 'bigint':
      case 'year':
        $ret = "'.self::quoteInt(".$expression.").'";
        break;

      case 'float':
      case 'double':
        $ret = "'.self::quoteFloat(".$expression.").'";
        break;

      case 'char':
      case 'varchar':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'binary':
      case 'varbinary':
        $ret = "'.self::quoteBinary(".$expression.").'";
        break;

      case 'decimal':
        $ret = "'.self::quoteDecimal(".$expression.").'";
        break;

      case 'time':
      case 'timestamp':
      case 'date':
      case 'datetime':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'enum':
      case 'set':
        $ret = "'.self::quoteString(".$expression.").'";
        break;

      case 'bit':
        $ret = "'.self::quoteBit(".$expression.").'";
        break;

      case 'tinytext':
      case 'text':
      case 'mediumtext':
      case 'longtext':
        $ret = ($lobAsString) ? $ret = "'.self::quoteString(".$expression.").'" : '?';
        break;

      case 'tinyblob':
      case 'blob':
      case 'mediumblob':
      case 'longblob':
        $ret = ($lobAsString) ? $ret = "'.self::quoteBinary(".$expression.").'" : '?';
        break;

      case 'list_of_int':
        $ret = "'.self::quoteListOfInt(".$expression.", '".
          addslashes($dataTypeInfo['delimiter'])."', '".
          addslashes($dataTypeInfo['enclosure'])."', '".
          addslashes($dataTypeInfo['escape'])."').'";
        break;

      default:
        throw new FallenException('data type', $dataTypeInfo['data_type']);
    }

    return $ret;
  }
public static function escapePhpExpression ( array $ dataTypeInfo , string $ expression , bool $ lobAsString ) : string { switch ( $ dataTypeInfo [ 'data_type' ] ) { case 'tinyint' : case 'smallint' : case 'mediumint' : case 'int' : case 'bigint' : case 'year' : $ ret = "'.self::quoteInt(" . $ expression . ").'" ; break ; case 'float' : case 'double' : $ ret = "'.self::quoteFloat(" . $ expression . ").'" ; break ; case 'char' : case 'varchar' : $ ret = "'.self::quoteString(" . $ expression . ").'" ; break ; case 'binary' : case 'varbinary' : $ ret = "'.self::quoteBinary(" . $ expression . ").'" ; break ; case 'decimal' : $ ret = "'.self::quoteDecimal(" . $ expression . ").'" ; break ; case 'time' : case 'timestamp' : case 'date' : case 'datetime' : $ ret = "'.self::quoteString(" . $ expression . ").'" ; break ; case 'enum' : case 'set' : $ ret = "'.self::quoteString(" . $ expression . ").'" ; break ; case 'bit' : $ ret = "'.self::quoteBit(" . $ expression . ").'" ; break ; case 'tinytext' : case 'text' : case 'mediumtext' : case 'longtext' : $ ret = ( $ lobAsString ) ? $ ret = "'.self::quoteString(" . $ expression . ").'" : '?' ; break ; case 'tinyblob' : case 'blob' : case 'mediumblob' : case 'longblob' : $ ret = ( $ lobAsString ) ? $ ret = "'.self::quoteBinary(" . $ expression . ").'" : '?' ; break ; case 'list_of_int' : $ ret = "'.self::quoteListOfInt(" . $ expression . ", '" . addslashes ( $ dataTypeInfo [ 'delimiter' ] ) . "', '" . addslashes ( $ dataTypeInfo [ 'enclosure' ] ) . "', '" . addslashes ( $ dataTypeInfo [ 'escape' ] ) . "').'" ; break ; default : throw new FallenException ( 'data type' , $ dataTypeInfo [ 'data_type' ] ) ; } return $ ret ; }
Returns PHP code escaping the value of a PHP expression that can be safely used when concatenating a SQL statement.

@param array  $dataTypeInfo Metadata of the column on which the field is based.
@param string $expression   The PHP expression.
@param bool   $lobAsString  A flag indication LOBs must be treated as strings.

@return string The generated PHP code.
Returns PHP code escaping the value of a PHP expression that can be safely used when concatenating a SQL statement .