Quote identifier if necessary.

@param string $value  The identifier to quote
@return string
541490
public function quoteIdentifier($value)
    {
        $quote = false;
        switch ($this->getConfig()->get(Formatter::CFG_QUOTE_IDENTIFIER_STRATEGY)) {
            case Formatter::QUOTE_IDENTIFIER_AUTO:
                $quote = ReservedWords::isReserved($value);
                break;

            case Formatter::QUOTE_IDENTIFIER_ALWAYS:
                $quote = true;
                break;
        }

        return $quote ? '`'.$value.'`' : $value;
    }
129458
protected function quoteIdentifier($str)
    {
        $open = '"';
        $close = '"';
        switch ($this->pdoDriver) {
            case 'mysql':
                $open = '`';
                $close = '`';
                break;
            case 'mssql':
                $open = '[';
                $close = ']';
                break;
        }
        return $open . str_replace($open, $open . $open, $str) . $close;
    }
1199643
protected static function sanitiseVariableValue($value)
        {
            $value = trim($value);

            if (!$value) {
                return '';
            }

            if (strpbrk($value[0], '"\'') !== false) { // value starts with a quote
                $quote = $value[0];

                $regexPattern = sprintf('/^
                    %1$s          # match a quote at the start of the value
                    (             # capturing sub-pattern used
                     (?:          # we do not need to capture this
                      [^%1$s\\\\] # any character other than a quote or backslash
                      |\\\\\\\\   # or two backslashes together
                      |\\\\%1$s   # or an escaped quote e.g \"
                     )*           # as many characters that match the previous rules
                    )             # end of the capturing sub-pattern
                    %1$s          # and the closing quote
                    .*$           # and discard any string after the closing quote
                    /mx',
                    $quote
                );

                $value = preg_replace($regexPattern, '$1', $value);
                $value = str_replace("\\$quote", $quote, $value);
                $value = str_replace('\\\\', '\\', $value);
            } else {
                $parts = explode(' #', $value, 2);
                $value = $parts[0];
            }

            return trim($value);
        }
1254040
public function quoteIdentifier($identifier)
    {
        $identifier = trim($identifier);

        if ($identifier === '*') {
            return '*';
        }

        if ($identifier === '') {
            return '';
        }

        // string
        if (preg_match('/^[\w-]+$/', $identifier)) {
            return $this->startQuote . $identifier . $this->endQuote;
        }

        // string.string
        if (preg_match('/^[\w-]+\.[^ \*]*$/', $identifier)) {
            $items = explode('.', $identifier);

            return $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
        }

        // string.*
        if (preg_match('/^[\w-]+\.\*$/', $identifier)) {
            return $this->startQuote . str_replace('.*', $this->endQuote . '.*', $identifier);
        }

        return $identifier;
    }
95877
protected function escape($value)
    {
        if ($value === null) {
            return 'NULL';
        }

        if (is_integer($value) || is_float($value)) {
            return $value;
        }

        return $this->pdo->quote($value);
    }
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);
    }
921920
protected function _quote($value) {
        $char = $this->getConfig('quoteCharacter');

        return $char . str_replace($char, '', $value) . $char;
    }
249468
public function quoteIfNecessary($value)
    {
        if ($this->isNumber($value) || $this->isPlaceholder($value)) {
            return $value;
        }

        return $this->quote($value);
    }
633136
protected function quote($conn, $value)
    {
        if ($conn instanceof PDO) {
            return $conn->quote($value);
        } elseif (is_resource($conn)) {
            $value = str_replace("'", "''", $value);
            $value = str_replace("\0", "[NULL]", $value);
            return "N'$value'";
        } else {
            user_error('Invalid database connection', E_USER_ERROR);
        }
        return null;
    }
948626
public function quote($value)
	{
		// PDO::quote() does not work as it should ...
		if ($value instanceof FlupdoRawSql) {
			return $value;
		} else if (is_bool($value)) {
			return $value ? 'TRUE' : 'FALSE';
		} else if (is_null($value)) {
			return 'NULL';
		} else if (is_int($value)) {
			return (string) $value;
		} else if (is_float($value)) {
			return sprintf('%F', $value);
		} else {
			// ignore locales when converting to string
			return $this->pdo->quote(strval($value), \PDO::PARAM_STR);
		}
	}
1064987
private function performQuoteIdentifier($value, $auto = false)
    {
        if ($auto === false || $this->autoQuoteIdentifiers === true) {
            $q = '`';
            return ($q . str_replace("$q", "$q$q", $value) . $q);
        }

        return $value;
    }
717635
public static function quote($value, $empty = 'NULL')
    {
        if (is_array($value)) return '(' . join(', ', array_map(array(get_class(), 'quote'), $value)) . ')';

        if (is_null($value)) return $empty;
        if (is_bool($value)) return $value ? 'TRUE' : 'FALSE';
        if (is_int($value) || is_float($value)) return (string)$value;
        return '"' . strtr((string)$value, array('\\' => '\\\\', "\0" => '\\0', "\r" => '\\r', "\n" => '\\n', '"' => '\\"')) . '"';
    }
285282
function quoteIdentifier( $identifier ) {

        $delimiter = $this->identifierDelimiter;

        if ( empty( $delimiter ) ) return $identifier;

        $identifier = explode( ".", $identifier );

        $identifier = array_map(
            function( $part ) use ( $delimiter ) { return $delimiter . str_replace( $delimiter, $delimiter.$delimiter, $part ) . $delimiter; },
            $identifier
        );

        return implode( ".", $identifier );

    }
1029065
public function quote($value)
    {
        $PdoConnection = $this->getPdoConnection();
        
        // If a PDO database connection is set, use it to quote the value using
        // the underlying database. Otherwise, quote it manually.
        if ($PdoConnection) {
            return $PdoConnection->quote($value);
        } elseif (is_null($value)) {
            return "NULL";
        } else {
            return "'" . addslashes($value) . "'";
        }
    }
394932
public function quote($value)
    {
        // If a PDO database connection is set, use it to quote the value using
        // the underlying database. Otherwise, quote it manually.
        if ($pdo = $this->getPdo()) {
            return $pdo->quote($value);
        }

        if (\is_numeric($value)) {
            return $value;
        }

        if (null === $value) {
            return 'NULL';
        }

        return "'" . \addslashes($value) . "'";
    }
107981
public function quote(string $value, int $type = \PDO::PARAM_STR): string
    {
        return $this->handler()->quote($value, $type);
    }
785370
private function convertToLabel($value)
    {
        $value = preg_replace('/(?<!-)-(?!-)/U', ' ', $value);
        $value = preg_replace('/(?<!-)--(?!-)/U', '-', $value);
        $value = preg_replace('/(?<!-)---(?!-)/U', ' - ', $value);

        return $value;
    }