mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Added some more operators.
Attribute + {n} is still not working.
This commit is contained in:
parent
6c87be97ef
commit
9269a6dcde
2 changed files with 21 additions and 0 deletions
|
@ -737,4 +737,16 @@ class Set2Test extends CakeTestCase {
|
|||
$this->assertEquals(5, $result[3]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test comparison operators.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExtractAttributeComparison() {
|
||||
$data = self::articleData();
|
||||
|
||||
$result = Set2::extract($data, '{n}.Comment.{n}.[user_id > 2]');
|
||||
$this->assertEquals($data[0]['Comment'][1], $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ class Set2 {
|
|||
} else {
|
||||
// attributes
|
||||
foreach ($item as $k => $v) {
|
||||
debug(array($k => $v));
|
||||
if (self::_matches(array($k => $v), $token)) {
|
||||
$next[] = $v;
|
||||
}
|
||||
|
@ -211,6 +212,14 @@ class Set2 {
|
|||
return $prop == $val;
|
||||
} elseif ($op === '!=') {
|
||||
return $prop != $val;
|
||||
} elseif ($op === '>') {
|
||||
return $prop > $val;
|
||||
} elseif ($op === '<') {
|
||||
return $prop < $val;
|
||||
} elseif ($op === '>=') {
|
||||
return $prop >= $val;
|
||||
} elseif ($op === '<=') {
|
||||
return $prop <= $val;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue