Adding fix for IN( sql.

Merging fixes between versions

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3792 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-11-01 19:19:11 +00:00
parent 613bb29300
commit f187ac9cef

View file

@ -833,7 +833,6 @@ class DboSource extends DataSource {
* @return unknown * @return unknown
*/ */
function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
$this->__scrubQueryData($queryData); $this->__scrubQueryData($queryData);
$this->__scrubQueryData($assocData); $this->__scrubQueryData($assocData);
$joinedOnSelf = false; $joinedOnSelf = false;
@ -848,9 +847,8 @@ class DboSource extends DataSource {
} else { } else {
$joinFields = null; $joinFields = null;
} }
// Generates primary query
$sql = 'SELECT ';
$sql = 'SELECT ';
if ($this->goofyLimit) { if ($this->goofyLimit) {
$sql .= $this->limit($queryData['limit'], $queryData['offset']); $sql .= $this->limit($queryData['limit'], $queryData['offset']);
} }
@ -1426,12 +1424,18 @@ class DboSource extends DataSource {
$keys = array_keys($value); $keys = array_keys($value);
if ($keys[0] === 0) { if ($keys[0] === 0) {
$data = $this->name($key) . ' IN ('; $data = $this->name($key) . ' IN (';
foreach($value as $valElement) { if (strpos($value[0], '-!') === 0){
$data .= $this->value($valElement) . ', '; $value[0] = str_replace('-!', '', $value[0]);
$data .= $value[0];
$data .= ')';
} else {
foreach($value as $valElement) {
$data .= $this->value($valElement) . ', ';
}
$data[strlen($data) - 2] = ')';
} }
$data[strlen($data) - 2] = ')';
} else { } else {
$out[] = '(' . join(')' . $join . '(', $this->conditionKeysToString($value)) . ')'; $out[] = '(' . join(') AND (', $this->conditionKeysToString($value)) . ')';
} }
} elseif(is_numeric($key)) { } elseif(is_numeric($key)) {
$data = ' ' . $value; $data = ' ' . $value;
@ -1439,7 +1443,7 @@ class DboSource extends DataSource {
$data = $this->name($key) . ' IS NULL'; $data = $this->name($key) . ' IS NULL';
} elseif($value === '') { } elseif($value === '') {
$data = $this->name($key) . " = ''"; $data = $this->name($key) . " = ''";
} elseif(preg_match('/^([a-z]*\\([a-z0-9]*\\)\\x20?|(?:like\\x20)|(?:or\\x20)|(?:not\\x20)|(?:between\\x20)|(?:regexp\\x20)|[<> = !]{1,3}\\x20?)?(.*)/i', $value, $match)) { } elseif(preg_match('/^([a-z]*\\([a-z0-9]*\\)\\x20?|(?:like\\x20)|(?:or\\x20)|(?:not\\x20)|(?:in\\x20)|(?:between\\x20)|(?:regexp\\x20)|[<> = !]{1,3}\\x20?)?(.*)/i', $value, $match)) {
if (preg_match('/(\\x20[\\w]*\\x20)/', $key, $regs)) { if (preg_match('/(\\x20[\\w]*\\x20)/', $key, $regs)) {
$clause = $regs['1']; $clause = $regs['1'];
$key = preg_replace('/' . $regs['1'] . '/', '', $key); $key = preg_replace('/' . $regs['1'] . '/', '', $key);