Adding fix for misquoted SQL functions (Ticket #2199)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4861 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-04-16 21:49:28 +00:00
parent 97aa991f2d
commit 86d32e4313

View file

@ -270,10 +270,10 @@ class DboMssql extends DboSource {
$dot = strrpos($fields[$i], '.');
$fieldAlias = count($this->__fieldMappings);
if ($dot === false) {
if ($dot === false && !preg_match('/\s+AS\s+/i', $fields[$i])) {
$this->__fieldMappings[$alias . '__' . $fieldAlias] = $alias . '.' . $fields[$i];
$fields[$i] = $this->name($alias) . '.' . $this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fieldAlias);
} elseif (!preg_match('/\]\.\[[^\s]+ AS \[/', $fields[$i])) {
} elseif (!preg_match('/\s+AS\s+/i', $fields[$i])) {
$build = explode('.', $fields[$i]);
$this->__fieldMappings[$build[0] . '__' . $fieldAlias] = $build[0] . '.' . $build[1];
$fields[$i] = $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $fieldAlias);