Skip to content

Commit 2852ae9

Browse files
committed
#19 - add criterions dynamically
1 parent 5fd877e commit 2852ae9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-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)

0 commit comments

Comments
 (0)