Solar_Sql_Adapter::quoteName PHP Méthode

quoteName() public méthode

If the name contains ' AS ', this method will separately quote the parts before and after the ' AS '. If the name contains a space, this method will separately quote the parts before and after the space. If the name contains a dot, this method will separately quote the parts before and after the dot.
See also: _quoteName()
public quoteName ( string | array $spec ) : string | array
$spec string | array The identifier name to quote. If an array, quotes each element in the array as an identifier name.
Résultat string | array The quoted identifier name (or array of names).
    public function quoteName($spec)
    {
        if (is_array($spec)) {
            foreach ($spec as $key => $val) {
                $spec[$key] = $this->quoteName($val);
            }
            return $spec;
        }
        // no extraneous spaces
        $spec = trim($spec);
        // `original` AS `alias` ... note the 'rr' in strripos
        $pos = strripos($spec, ' AS ');
        if ($pos) {
            // recurse to allow for "table.col"
            $orig = $this->quoteName(substr($spec, 0, $pos));
            // use as-is
            $alias = $this->_quoteName(substr($spec, $pos + 4));
            return "{$orig} AS {$alias}";
        }
        // `original` `alias`
        $pos = strrpos($spec, ' ');
        if ($pos) {
            // recurse to allow for "table.col"
            $orig = $this->quoteName(substr($spec, 0, $pos));
            // use as-is
            $alias = $this->_quoteName(substr($spec, $pos + 1));
            return "{$orig} {$alias}";
        }
        // `table`.`column`
        $pos = strrpos($spec, '.');
        if ($pos) {
            // use both as-is
            $table = $this->_quoteName(substr($spec, 0, $pos));
            $col = $this->_quoteName(substr($spec, $pos + 1));
            return "{$table}.{$col}";
        }
        // `name`
        return $this->_quoteName($spec);
    }