roundcubemail/program/lib/Roundcube/rcube_db.php
public function quote($input, $type = null)
    {
        // handle int directly for better performance
        if ($type == 'integer' || $type == 'int') {
            return intval($input);
        }

        if (is_null($input)) {
            return 'NULL';
        }

        if ($input instanceof DateTime) {
            return $this->quote($input->format($this->options['datetime_format']));
        }

        if ($type == 'ident') {
            return $this->quote_identifier($input);
        }

        // create DB handle if not available
        if (!$this->dbh) {
            $this->db_connect('r');
        }

        if ($this->dbh) {
            $map = array(
                'bool'    => PDO::PARAM_BOOL,
                'integer' => PDO::PARAM_INT,
            );

            $type = isset($map[$type]) ? $map[$type] : PDO::PARAM_STR;

            return strtr($this->dbh->quote($input, $type),
                // escape ? and `
                array('?' => '??', self::DEFAULT_QUOTE => self::DEFAULT_QUOTE.self::DEFAULT_QUOTE)
            );
        }

        return 'NULL';
    }
public function quote($input, $type = null)
    {
        // handle int directly for better performance
        if ($type == 'integer' || $type == 'int') {
            return intval($input);
        }

        if (is_null($input)) {
            return 'NULL';
        }

        if ($input instanceof DateTime) {
            return $this->quote($input->format($this->options['datetime_format']));
        }

        if ($type == 'ident') {
            return $this->quote_identifier($input);
        }

        // create DB handle if not available
        if (!$this->dbh) {
            $this->db_connect('r');
        }

        if ($this->dbh) {
            $map = array(
                'bool'    => PDO::PARAM_BOOL,
                'integer' => PDO::PARAM_INT,
            );

            $type = isset($map[$type]) ? $map[$type] : PDO::PARAM_STR;

            return strtr($this->dbh->quote($input, $type),
                // escape ? and `
                array('?' => '??', self::DEFAULT_QUOTE => self::DEFAULT_QUOTE.self::DEFAULT_QUOTE)
            );
        }

        return 'NULL';
    }
public function quote ( $ input , $ type = null ) { // handle int directly for better performance if ( $ type == 'integer' || $ type == 'int' ) { return intval ( $ input ) ; } if ( is_null ( $ input ) ) { return 'NULL' ; } if ( $ input instanceof DateTime ) { return $ this -> quote ( $ input -> format ( $ this -> options [ 'datetime_format' ] ) ) ; } if ( $ type == 'ident' ) { return $ this -> quote_identifier ( $ input ) ; } // create DB handle if not available if ( ! $ this -> dbh ) { $ this -> db_connect ( 'r' ) ; } if ( $ this -> dbh ) { $ map = array ( 'bool' => PDO :: PARAM_BOOL , 'integer' => PDO :: PARAM_INT , ) ; $ type = isset ( $ map [ $ type ] ) ? $ map [ $ type ] : PDO :: PARAM_STR ; return strtr ( $ this -> dbh -> quote ( $ input , $ type ) , // escape ? and ` array ( '?' => '??' , self :: DEFAULT_QUOTE => self :: DEFAULT_QUOTE . self :: DEFAULT_QUOTE ) ) ; } return 'NULL' ; }
Formats input so it can be safely used in a query

@param mixed  $input Value to quote
@param string $type  Type of data (integer, bool, ident)

@return string Quoted/converted string for use in query
Formats input so it can be safely used in a query