diff --git a/src/CustomerList/Filter/CustomerSegment.php b/src/CustomerList/Filter/CustomerSegment.php index 82d7bc9f..70208565 100644 --- a/src/CustomerList/Filter/CustomerSegment.php +++ b/src/CustomerList/Filter/CustomerSegment.php @@ -227,25 +227,28 @@ protected function addJoin( ); $condition = $baseCondition; - $valuePlaceholder = $joinName . '_value'; - $parameterType = ParameterType::INTEGER; if ($this->type === self::OPERATOR_OR) { // must match any of the passed IDs + + $valueKeys = array_keys($conditionValue); + $isNumericArray = $valueKeys == array_filter($valueKeys, 'is_numeric'); + if (!$isNumericArray){ + throw Exception('Invalid condition value'); + } + $condition .= sprintf( ' AND %1$s.dest_id IN (%2$s)', $joinName, - ':' . $valuePlaceholder + implode(',', $valueKeys) ); - $value = array_keys($conditionValue); - $parameterType = Connection::PARAM_INT_ARRAY; + } else { // runs an extra join for every ID - all joins must match $condition .= sprintf( - ' AND %1$s.dest_id = %2$s', + ' AND %1$s.dest_id = %2$d', $joinName, - ':' . $valuePlaceholder + is_numeric($conditionValue) ? $conditionValue : '0' ); - $value = $conditionValue; } $queryBuilder->join( @@ -255,6 +258,5 @@ protected function addJoin( $condition ); - $queryBuilder->setParameter($valuePlaceholder, $value, $parameterType); } }