Quote string
@return string
@param $val mixed
@param $type int
423843
function quote($val,$type=\PDO::PARAM_STR) {
		return $this->engine=='odbc'?
			(is_string($val)?
				\Base::instance()->stringify(str_replace('\'','\'\'',$val)):
				$val):
			$this->pdo->quote($val,$type);
	}
431476
protected function _quote( $value )
    {
        if ( $value === null )
            return 'NULL';
        elseif ( is_integer( $value ) )
        {
            return $this->db->quote( $value, PDO::PARAM_INT );
        }
        else
        {
            return $this->db->quote( $value, PDO::PARAM_STR );
        }
    }
1081793
function quote($filter = array(), $join = " AND ") {
		$QUOTE_CHAR = defined('DB::USE_ANSI_SQL') ? '"' : '';

		$string = '';
		$sep = '';

		foreach ($filter as $field => $value) {
			// first break the field up into its two components
			$operator = '';
			if (is_string($field)) {
				list($field, $operator) = explode(' ', trim($field));
			}

			if (is_array($value)) {
				// quote each individual one into a string
				$ins = '';
				$insep = '';
				foreach ($value as $v) {
					$ins .= $insep . Convert::raw2sql($v);
					$insep = ',';
				}
				$value = '('.$ins.')';
			} else if (is_null($value)) {
				$value = 'NULL';
			} else if (is_string($field)) {
				$value = "'" . Convert::raw2sql($value) . "'";
			}

			if (strpos($field, '.')) {
				list($tb, $fl) = explode('.', $field);
				$string .= $sep . $QUOTE_CHAR . $tb . $QUOTE_CHAR . '.' . $QUOTE_CHAR . $fl . $QUOTE_CHAR . " $operator " . $value;
			} else {
				if (is_numeric($field)) {
					$string .= $sep . $value;
				} else {
					$string .= $sep . $QUOTE_CHAR . $field . $QUOTE_CHAR . " $operator " . $value;
				}
			}

			$sep = $join;
		}

		return $string;
	}
29275
public function quote(?string $value): string
    {
        if ($value === null) {
            return 'NULL';
        }

        return $this->pdo->quote($value);
    }
1160402
public function literal($input, $type = null)
    {
        // TODO remove
        if (!is_string($input)) {
            return $input;
        }
        // TODO remove

        return $this->connection->quote($input, $type);
    }
1315957
public function quoteOrNot($val)
    {
        return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val;
    }
953348
protected function quote($value)
    {
        if ($value === null) {
            return 'NULL';
        }

        if (is_array($value)) {
            return join(', ', array_map([$this, 'quote'], $value));
        }

        return is_string($value)
            ? ('"' . $this->server->real_escape_string($value) . '"')
            : (is_float($value) ? (float)$value : (int)$value);
    }
1113779
public function quote($value, $type = null)
    {
        list($value, $type) = $this->cast($value, $type);

        return $this->_driver->quote($value, $type);
    }
1360286
protected function _quote($value)
    {
        if (is_int($value) || is_float($value)) {
            return $value;
        }
        /**
         * Use db2_escape_string() if it is present in the IBM DB2 extension.
         * But some supported versions of PHP do not include this function,
         * so fall back to default quoting in the parent class.
         */
        if (function_exists('db2_escape_string')) {
            return "'" . db2_escape_string($value) . "'";
        }
        return parent::_quote($value);
    }
513306
public static function lowercase($val): string
    {
        if (!$val || !\is_string($val)) {
            return \is_int($val) ? $val : '';
        }

        if (\function_exists('mb_strtolower')) {
            return \mb_strtolower($val, 'utf-8');
        }

        return \strtolower($val);
    }
918741
public function escape($value, $type){
		switch($type){
			case Manager::BOOL:
				return $this->resource->quote($value, PDO::PARAM_BOOL);

			case Manager::TEXT:
				return $this->resource->quote($value, PDO::PARAM_STR);

			case Manager::IDENTIFIER:
				switch($this->driverName){
					case 'mysql':
						return str_replace('`*`', '*', '`' . str_replace('.', '`.`', str_replace('`', '``', $value)) . '`');

					case 'pgsql':
						return '"' . str_replace('.', '"."', str_replace('"', '""', $value)) . '"';

					case 'sqlite':
					case 'sqlite2':
						return str_replace('[*]', '*', '[' . str_replace('.', '].[', $value) . ']');

					case 'odbc':
					case 'oci':
					case 'mssql':
						return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';

					default:
						return $value;
				}

			case Manager::BINARY:
				return $this->resource->quote($value, PDO::PARAM_LOB);

			case Manager::DATETIME:
				return ($value instanceof DateTime) ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);

			default:
				throw new InvalidArgumentException('Unsupported data type.');
				break;
		}
	}
419251
function type($val) {
		switch (gettype($val)) {
			case 'NULL':
				return \PDO::PARAM_NULL;
			case 'boolean':
				return \PDO::PARAM_BOOL;
			case 'integer':
				return \PDO::PARAM_INT;
			case 'resource':
				return \PDO::PARAM_LOB;
			case 'float':
				return self::PARAM_FLOAT;
			default:
				return \PDO::PARAM_STR;
		}
	}
269688
function quote( $value ) {

        $value = $this->format( $value );

        if ( $value === null ) {

            return "NULL";

        }

        if ( $value === false ) {

            return "'0'";

        }

        if ( $value === true ) {

            return "'1'";

        }

        if ( is_int( $value ) ) {

            return "'" . ( (string) $value ) . "'";

        }

        if ( is_float( $value ) ) {

            return "'" . sprintf( "%F", $value ) . "'";

        }

        if ( $value instanceof Literal ) {

            return $value->value;

        }

        return $this->pdo->quote( $value );

    }
1032372
public function quoteString(string $data): string
    {
        if ($this->handle === null) {
            throw new TransactionError("The transaction has been committed or rolled back");
        }

        return $this->handle->quoteString($data);
    }
857219
public function quote($string, $parameter_type = self::PARAM_STR)
	{
		return $this->driver->quoteString($string, $parameter_type);
	}
1359911
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);
        }

        switch ($type) {
        case 'bool':
        case 'integer':
            return intval($input);
        default:
            return "'" . strtr($input, array(
                    '?' => '??',
                    "'" => "''",
                    rcube_db::DEFAULT_QUOTE => rcube_db::DEFAULT_QUOTE . rcube_db::DEFAULT_QUOTE
            )) . "'";
        }
    }
212031
def urlquote(val):
    
    if val is None: return ''
    if not isinstance(val, unicode): val = str(val)
    else: val = val.encode('utf-8')
    return urllib.quote(val)