Skip to content

Commit d9dbc6a

Browse files
committed
Releasing 1.2.2
2 parents c2cbaab + 171374e commit d9dbc6a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/TgDatabase/Criterion/LogicalExpression.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ public function __construct($op, ...$criterions) {
1616
}
1717
}
1818

19+
/**
20+
* Dynamically add more criterions to the expression.
21+
* @param mixed $criterions - more criterions to be added.
22+
*/
23+
public function add(...$criterions) {
24+
if ((count($criterions) == 1) and is_array($criterions[0])) {
25+
$this->criterions = array_merge($this->criterions, $criterions[0]);
26+
} else {
27+
$this->criterions = array_merge($this->criterions, $criterions);
28+
}
29+
return $this;
30+
}
31+
1932
/**
2033
* Render the SQL fragment.
2134
* @param Criteria $localCriteria - local criteria object (e.g. subquery)

src/TgDatabase/Restrictions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,19 @@ public static function notIn($propertyName, $values) {
121121
* Apply an "and" conjunction.
122122
*/
123123
public static function and(...$expressions) {
124+
if ((count($expressions) == 1) && is_array($expressions[0])) {
125+
return new LogicalExpression('AND', $expressions[0]);
126+
}
124127
return new LogicalExpression('AND', $expressions);
125128
}
126129

127130
/**
128131
* Apply an "or" conjunction.
129132
*/
130133
public static function or(...$expressions) {
134+
if ((count($expressions) == 1) && is_array($expressions[0])) {
135+
return new LogicalExpression('OR', $expressions[0]);
136+
}
131137
return new LogicalExpression('OR', $expressions);
132138
}
133139

0 commit comments

Comments
 (0)