diff --git a/src/dba/AbstractModelFactory.php b/src/dba/AbstractModelFactory.php index dadc16847..13dfd2274 100755 --- a/src/dba/AbstractModelFactory.php +++ b/src/dba/AbstractModelFactory.php @@ -690,7 +690,7 @@ private function filterWithJoin(array $options): array|AbstractModel { if (array_key_exists(Factory::FILTER, $options)) { $query .= $this->applyFilters($vals, $options[Factory::FILTER]); } - + // Apply order filter if (!array_key_exists(Factory::ORDER, $options)) { // Add a asc order on the primary keys as a standard @@ -706,7 +706,7 @@ private function filterWithJoin(array $options): array|AbstractModel { $dbh = self::getDB(); $stmt = $dbh->prepare($query); $stmt->execute($vals); - + $res = array(); $values = array(); foreach ($factories as $factory) { @@ -816,20 +816,29 @@ private function applyFilters(&$vals, Filter|array $filters, bool $isJoinFilter continue; } $v = $filter->getValue(); - if (is_array($v)) { - foreach ($v as $val) { - $vals[] = $val; - } - } - else { - $vals[] = $v; - } + $this->getAllArrayValues($vals, $v); } if ($isJoinFilter) { return " AND " . implode(" AND ", $parts); } return " WHERE " . implode(" AND ", $parts); } + + /** + * @param $vals + * @param $element + * @return array + */ + private function getAllArrayValues(&$vals, $element) { + if (!is_array($element)) { + $vals[] = $element; + return; + } + + foreach($element as $v) { + $this->getAllArrayValues($vals, $v); + } + } /** * @param $orders Order|Order[]