Quote a string that is used as an identifier
(table names, column names Or table.column types etc).

@param $identifier

@return string
518648
protected function quoteOneIdentifier($identifier)
    {
        $parts = explode('.', $identifier);
        $parts = array_map([$this, 'quoteIdentifierSection'], $parts);

        return implode('.', $parts);
    }
790469
protected function quoteTable($table)
    {
        # The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names
        if ($this->mode == "odbc") {
            return $table;
        }

        $table = trim($table);

        # There is a standard function for quoting postgres table names
        if (in_array($this->mode, ["postgres", "redshift"], true)) {
            $this->connect();
            return pg_escape_identifier($this->server, $table);
        }

        $chars = $this->quoteChars[$this->mode];

        if (is_array($chars)) {
            $from = $chars[0];
            $to = $chars[1];
        } else {
            $from = $chars;
            $to = $chars;
        }

        $quoted = $from . $table . $to;

        return $quoted;
    }
481370
public function ident($value, $quote = '`')
    {
        $value = preg_replace('/[^A-Za-z0-9_]+/', '', $value);
        if (strpos($value, '.') !== false) {
            $values = explode('.', $value);
            $value = $quote . implode($quote . '.' . $quote, $values) . $quote;
        } else {
            $value = $quote . $value . $quote;
        }

        return $value;
    }
916589
protected function _quoteIdentifierExpression(IdentifierExpression $expression)
    {
        $expression->setIdentifier(
            $this->_driver->quoteIdentifier($expression->getIdentifier())
        );
    }
819590
public function quoteIdentifier( $identifier )
    {
        if ( sizeof( $this->identifierQuoteChars ) === 2 )
        {
            $identifier = 
                $this->identifierQuoteChars["start"]
                . str_replace( 
                    $this->identifierQuoteChars["end"],
                    $this->identifierQuoteChars["end"].$this->identifierQuoteChars["end"],
                    $identifier
                  )
                . $this->identifierQuoteChars["end"];
        }
        return $identifier;
    }
576688
protected function quoteIdentifier($identifier)
    {
        if (is_array($identifier)) {
            $result = array_map([$this, 'quoteOneIdentifier'], $identifier);

            return implode(', ', $result);
        }

        return Inflector::tabilize($this->quoteOneIdentifier(lcfirst($identifier)));
    }
500752
protected function _quoteJoins($joins)
    {
        $result = [];
        foreach ($joins as $value) {
            $alias = null;
            if (!empty($value['alias'])) {
                $alias = $this->_driver->quoteIdentifier($value['alias']);
                $value['alias'] = $alias;
            }

            if (is_string($value['table'])) {
                $value['table'] = $this->_driver->quoteIdentifier($value['table']);
            }

            $result[$alias] = $value;
        }

        return $result;
    }
701065
public function render($identifier)
    {
        return (isset($this->authenticationProviderSettings[$identifier]['label']) ? $this->authenticationProviderSettings[$identifier]['label'] : $identifier);
    }
508872
private function _key($identifier) {
    	extract($identifier);
    	$arg_string = "";
    	return md5(serialize($class . $method . implode('~', $args)));
    }
871624
public static String quoteIdentifier(String identifier, boolean isH2DataBase) {
        if((isH2DataBase && (Constants.H2_RESERVED_WORDS.contains(identifier.toUpperCase())
                        || !H2_SPECIAL_NAME_PATTERN.matcher(identifier).find())) ||
                (!isH2DataBase && (Constants.POSTGIS_RESERVED_WORDS.contains(identifier.toUpperCase())
                        || !POSTGRE_SPECIAL_NAME_PATTERN.matcher(identifier).find()))) {
            return quoteIdentifier(identifier);
        } else {
            return identifier;
        }
    }
1207227
public function quoteIdentifier($value)
    {
        if ($value instanceof Expr) {
            return $value->getValue();
        }

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

        $pieces = explode('.', $value);

        foreach ($pieces as $key => $piece) {
            $pieces[$key] = '`'.$piece.'`';
        }

        return implode('.', $pieces);
    }
282887
public function quoteIdent($identifier)
	{
		if (\is_array($identifier))
		{
			return array_map([$this, __METHOD__], $identifier);
		}

		// Handle comma-separated identifiers
		if (strpos($identifier, ',') !== FALSE)
		{
			$parts = array_map('mb_trim', explode(',', $identifier));
			$parts = array_map([$this, __METHOD__], $parts);
			$identifier = implode(',', $parts);
		}

		// Split each identifier by the period
		$hiers = explode('.', $identifier);
		$hiers = array_map('mb_trim', $hiers);

		// Re-compile the string
		$raw = implode('.', array_map([$this, '_quote'], $hiers));

		// Fix functions
		$funcs = [];
		preg_match_all("#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\((.*?)\))){$this->escapeCharClose}#iu", $raw, $funcs, PREG_SET_ORDER);
		foreach($funcs as $f)
		{
			// Unquote the function
			$raw = str_replace($f[0], $f[1], $raw);

			// Quote the inside identifiers
			$raw = str_replace($f[3], $this->quoteIdent($f[3]), $raw);
		}

		return $raw;
	}
856383
public function quote($string, $type='string')
    {
        if ($type == 'string') {
            return "'" . str_replace("'", "''", $string) . "'";
        }

        if ($type != 'name') {
            throw new InvalidArgumentException("type has to be either string|name, not $type");
        }

        return '"' . str_replace('"', '""', $string) . '"';
    }
962793
protected static function _parseIdentifier($identifier)
    {
        $parts = array();
        $hash  = $identifier;

        // Validate the variable format
        if (strpos($identifier, '.') !== false) {
            // Split the variable name into it's parts
            $parts = explode('.', $identifier);

            // Validate the hash name
            $hash   = array_shift($parts);
        }

        $hash = strtoupper($hash);

        return array($hash, $parts);
    }
1171283
public static function quoteIdentifier($identifier, $tableName = null)
    {
        if ($identifier === null || $identifier === '') {
            return '';
        }

        if (!is_string($identifier)) {
            throw new InvalidArgumentException(sprintf(
                'Field Name must be a string, received %s',
                is_object($identifier) ? get_class($identifier) : gettype($identifier)
            ));
        }

        if ($tableName !== null) {
            if (!is_string($tableName)) {
                throw new InvalidArgumentException(sprintf(
                    'Table Name must be a string, received %s',
                    is_object($tableName) ? get_class($tableName) : gettype($tableName)
                ));
            }

            if ($tableName === '') {
                throw new InvalidArgumentException(
                    'Table Name can not be empty.'
                );
            }

            if ($identifier === '*') {
                $template = '%1$s.*';
            } else {
                $template = '%1$s.`%2$s`';
            }

            return sprintf($template, $tableName, $identifier);
        }

        if ($identifier === '*') {
            return $identifier;
        } else {
            return sprintf('`%1$s`', $identifier);
        }
    }
1257444
protected function quoteIdentifierSection($part)
    {
        if ($part === '*') {
            return $part;
        }

        $quoteCharacter = '`';
        // double up any identifier quotes to escape them
        return $quoteCharacter.
        str_replace(
            $quoteCharacter,
            $quoteCharacter.$quoteCharacter,
            $part
        ).$quoteCharacter;
    }
596814
public static function stringify_identifier($identifier)
	{
		// Identifier may not be empty, but can be false or 0
		if ($identifier === '' || $identifier === null)
		{
			throw new \FuelException('The identifier cannot be empty, must contain a value of any kind other than null or an empty string.');
		}

		// In case of string or int just return it as a string
		if (is_string($identifier) || is_int($identifier))
		{
			// cleanup to only allow alphanum chars, dashes, dots & underscores
			if (preg_match('/^([a-z0-9_\.\-]*)$/iuD', $identifier) === 0)
			{
				throw new \FuelException('Cache identifier can only contain alphanumeric characters, underscores, dashes & dots.');
			}

			return (string) $identifier;
		}
		// In case of array, bool or object return the md5 of the $identifier's serialization
		else
		{
			return '_hashes.'.md5(serialize($identifier));
		}
	}