Driver_Database_Driver_MySQLI::_quote_identifier
null Driver_Database_Driver_MySQLI::_quote_identifier( )
File: ./drivers/database/mysqli/mysqli.class.php
protected function _quote_identifier($column)
{
if (is_array($column))
ist($column, $alias) = $column;
if (is_object($column))
{
if ($column instanceof Database)
{
// Create a sub-query
$column = '(' . $column->compile() . ')';
}
elseif ($column instanceof Database_Expression)
{
// Use a raw expression
$column = $column->value();
}
else
{
// Convert the object to a string
$column = $this->_quote_identifier((string)$column);
}
}
se
转换为字符串
column = trim((string)$column);
f (preg_match('#^(.*) AS (.*)$#i',$column,$m))
$column = $m[1];
$alias = $m[2];
f ($column === '*')
return $column;
lseif (strpos($column, '"') !== false)
// Quote the column in FUNC("column") identifiers
$column = preg_replace('/"(.+?)"/e', '$this->_quote_identifier("$1")', $column);
lseif (strpos($column, '.') !== false)
$parts = explode('.', $column);
$prefix = $this->config['table_prefix'];
if ($prefix)
{
// Get the offset of the table name, 2nd-to-last part
$offset = count($parts) - 2;
if (!$this->_as_table || !in_array($parts[$offset],$this->_as_table))
{
$parts[$offset] = $prefix . $parts[$offset];
}
}
foreach ($parts as & $part)
{
if ($part !== '*')
{
// Quote each of the parts
$this->_change_charset($part);
$part = $this->_identifier . str_replace($this->_identifier, '', $part) . $this->_identifier;
}
}
$column = implode('.', $parts);
lse
$this->_change_charset($column);
$column = $this->_identifier . str_replace($this->_identifier, '', $column) . $this->_identifier;
(isset($alias))
$this->_change_charset($alias);
column .= ' AS ' . $this->_identifier . str_replace($this->_identifier,'',$alias).$this->_identifier;
turn $column;
}