Adding NOT query conditions fix for Ticket #1793

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4167 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-12-23 21:24:30 +00:00
parent a420c70c91
commit 2ea8e4edee

View file

@ -1349,14 +1349,14 @@ class DboSource extends DataSource {
$c = 0; $c = 0;
$data = null; $data = null;
$out = array(); $out = array();
$bool = array('and', 'or', 'and not', 'or not', 'xor', '||', '&&'); $bool = array('and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&');
$join = ' AND '; $join = ' AND ';
foreach($conditions as $key => $value) { foreach($conditions as $key => $value) {
if (in_array(strtolower(trim($key)), $bool)) { if (in_array(strtolower(trim($key)), $bool)) {
$join = ' ' . strtoupper($key) . ' '; $join = ' ' . strtoupper($key) . ' ';
$value = $this->conditionKeysToString($value); $value = $this->conditionKeysToString($value);
if (strpos($join, 'NOT')) { if (strpos($join, 'NOT') !== false) {
$out[] = 'NOT (' . join(') ' . strtoupper($key) . ' (', $value) . ')'; $out[] = 'NOT (' . join(') ' . strtoupper($key) . ' (', $value) . ')';
} else { } else {
$out[] = '(' . join(') ' . strtoupper($key) . ' (', $value) . ')'; $out[] = '(' . join(') ' . strtoupper($key) . ' (', $value) . ')';