Adds backtics around argument. This will allow you to use reserved
SQL words as table or field names such as "table".

@param mixed $s Any string or array of strings

@return string Quoted string
769248
public function bt($s)
    {
        if (is_array($s)) {
            $out = array();
            foreach ($s as $ss) {
                $out[] = $this->bt($ss);
            }
            return $out;
        }

        if (!$this->bt
            || is_object($s)
            || $s === '*'
            || strpos($s, '.') !== false
            || strpos($s, '(') !== false
            || strpos($s, $this->bt) !== false
        ) {
            return $s;
        }

        return $this->bt.$s.$this->bt;
    }
1179534
public static function toNumbers($s){
		$ret = array();
		for($i=0; $i<strlen($s); $i+=2){
			$ret[] = hexdec(substr($s, $i, 2));
		}
		return $ret;
	}
321812
private function quoteApplicationVersion($s)
    {
        $quotedString = preg_replace('/ {2,}|\s/', ' ', $s);
        $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
        $quotedString = preg_replace('/\\(/', '\\(', $quotedString);
        return $quotedString;
    }
725505
public static function quoteFieldNames($fields)
    {
        $fieldArr = is_string($fields) ? explode(',', trim($fields)) : (array)$fields;
        
        foreach ($fieldArr as $k => $field) {
            $field = preg_replace("/(\s+)/", ' ', trim($field));
            if ($field == '*') {
                // do nothing
            } elseif (false !== strpos($field, '(')) {
                if (preg_match("/(.*?)\\((.*?)\\)(.*)/i", $field, $match)) {
                    // xx() | xx(xx) | xx(xx)xx
                    $field = $match[1] . '(' . QueryBuilder::quoteFieldName($match[2]).')' . QueryBuilder::quoteFieldName($match[3]);
                } else {
                    // xx( | xx(xx
                    $field = preg_replace_callback(
                        "/\\((.+)/i",
                        function($match) {
                            return '('.QueryBuilder::quoteFieldName($match[1]);
                        },
                        $field
                    );
                }

                $fieldArr[$k] = $field;
            } elseif (false !== strpos($field, ')')) {
                // xx)
                $field = preg_replace_callback(
                    "/(.*)\\)/i",
                    function($match) {
                        return QueryBuilder::quoteFieldName($match[1]) . ')';
                    },
                    $field
                );
                
                $fieldArr[$k] = QueryBuilder::quoteFieldName(substr($field, 0, strlen($field) - 1)) . ')';
            } else {
                $fieldArr[$k] = QueryBuilder::quoteFieldName($field);
            }
        }
        
        $rFields = implode(',', $fieldArr);        
        
        return $rFields;
    }
156867
public function getQuotedName(string $str): string
    {
        $platform = $this->connection->getDatabasePlatform();
        $keywords = $platform->getReservedKeywordsList();
        $parts = explode('.', $str);
        foreach ($parts as $k => $v) {
            $parts[$k] = ($keywords->isKeyword($v)) ? $platform->quoteIdentifier($v) : $v;
        }

        return implode('.', $parts);
    }
1319881
public static final String addQuotes(String szTableNames, char charStart, char charEnd)
    {
        String strFileName = szTableNames;
        if (charStart == -1)
            charStart = DBConstants.SQL_START_QUOTE;
        if (charEnd == -1)
            charEnd = DBConstants.SQL_END_QUOTE;

        for (int iIndex = 0; iIndex < strFileName.length(); iIndex++)
        {
            if ((strFileName.charAt(iIndex) == charStart)
                || (strFileName.charAt(iIndex) == charEnd))
            {   // If a quote is in this string, replace with a double-quote Fred's -> Fred''s
                strFileName = strFileName.substring(0, iIndex) + 
                    strFileName.substring(iIndex, iIndex + 1) + 
                    strFileName.substring(iIndex, iIndex + 1) + 
                    strFileName.substring(iIndex + 1, strFileName.length());
                iIndex++; // Skip the second quote
            }
        }
        if ((charStart != ' ') && (charEnd != ' '))
            strFileName = charStart + strFileName + charEnd;    // Spaces in name, quotes required
        return strFileName;
    }
350679
public static function charsToNormalTitle(string $s): string
    {
        if (is_array($s)) {
            $res = [];

            foreach ($s as $k => $v) {
                $res[$k] = strtr(ucfirst(strtolower($v)), ['_' => ' ']);
            }

            $s = $res;
        } elseif (is_string($s)) {
            $s = strtr(ucfirst(strtolower($s)), ['_' => ' ']);
        }

        return $s;
    }
769073
public function ifNotExists(string $sql): string
    {
        $sql = $this->c::mbTrim($sql);

        if (!preg_match('/^CREATE\s+TABLE\b/ui', $sql)) {
            return $sql; // Not applicable.
        }
        if (!preg_match('/^CREATE\s+TABLE\s+IF\s+NOT\s+EXISTS\b/ui', $sql)) {
            $sql = preg_replace('/^CREATE\s+TABLE\b/ui', 'CREATE TABLE IF NOT EXISTS', $sql);
        }
        return $sql;
    }
1168082
public function FormatTableName($Table) {

      if (strpos($Table, '.') !== FALSE){
         if(preg_match('/^([^\s]+)\s+(?:as\s+)?`?([^`]+)`?$/', $Table, $Matches)){
            $DatabaseTable = '`' . str_replace('.', '`.`', $Matches[1]) . '`';
            $Table = str_replace($Matches[1], $DatabaseTable, $Table);
         }else
            $Table = '`' . str_replace('.', '`.`', $Table) . '`';
      }
      return $Table;
   }
502923
private function transliterateHungarian($s)
    {
        $table = array(
            'á' => 'a',
            'é' => 'e',
            'í' => 'i',
            'ó' => 'o',
            'ö' => 'o',
            'ő' => 'o',
            'ú' => 'u',
            'ü' => 'u',
            'ű' => 'u',
        );
        return strtr($s, $table);
    }
1150825
private function _transliterateFrench ($s)
    {        
        $table = array (
            'â' => 'a',
            'ê' => 'e',
            'î' => 'i',
            'ô' => 'o',
            'û' => 'u',
            'Â' => 'A',
            'Ê' => 'E',
            'Î' => 'I',
            'Ô' => 'O',
            'Û' => 'U',
            'œ' => 'oe',
            'æ' => 'ae',
            'Ÿ' => 'Y',
            'ç' => 'c',
        	'Ç' => 'C',
        );
        return strtr($s, $table);
    }
1170269
public static function escapeAssertion($s)
    {
        if (0 === strpos($s, 'r.')) {
            $s = substr_replace($s, 'r_', 0, 2);
        }
        if (0 === strpos($s, 'p.')) {
            $s = substr_replace($s, 'p_', 0, 2);
        }

        $s = preg_replace_callback("~(\|| |=|\)|\(|&|<|>|,|\+|-|!|\*|\/)(r|p)(\.)~", function ($m) {
            return $m[1].$m[2].'_';
        }, $s);

        return $s;
    }
681393
public static function strict($s)
	{
		if (! ReflectionTypeHint::isValid()) return false;
		if (is_null($s)) return $s;
		return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s);
	}
678882
public function addPrefix($table) {
        if (strpos($table, '`') !== false) {
            return $table;
        }
        preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
        $table = count($match) == 2 ? $table : $match[1];
        $alias = '';
        if (count($match) > 2) {
            $alias = $match[2];
        }
        if (strpos($table, '.') !== false) {
            list($schema, $table) = explode('.', $table);
            return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
        }
        if (strpos($table, '!') === 0) {
            return sprintf('`%s`%s', substr($table, 1), $alias);
        }
        $prefix = $this->getEngine()->getConfig('prefix');
        if (empty($prefix)) {
            return sprintf('`%s`%s', $table, $alias);
        }
        return sprintf('`%s`%s', $prefix.
            Str::firstReplace($table, $prefix), $alias);
    }
1330503
private static function setFields($fields) {
        $fieldsString = '';
        $i = 0;
        foreach($fields as $key => $val) {
            $fieldsString .= ($i > 0 ? ",\n  " : '') . self::$_ops->addBackticks($key) .
                             self::$_ops->operandi($val, true, true);
            $i++;
        }
        return $fieldsString;
    }
1046927
protected function encodeStringLitralForNQuads($s)
    {
        $s = str_replace('\\', '\\\\', $s);
        $s = str_replace("\t", '\t', $s);
        $s = str_replace("\n", '\n', $s);
        $s = str_replace("\r", '\r', $s);
        $s = str_replace('"', '\"', $s);

        return $s;
    }
1272650
private function quoteAttributeName($s) {
	    $quotedString = $this->collapseWhitespace($s);
	    $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
	    $quotedString = preg_replace('/\\=/', '\\=', $quotedString);
	
	    return $quotedString;
    }