Skip to content

Commit a664e6c

Browse files
authored
Merge pull request #26 from dimitriadisg/patch-1
BUGFIX: Fix SqLiteIndex for multi-dimensional arrays
2 parents ab02948 + 7b0be6d commit a664e6c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Classes/Domain/Service/SqLiteIndex.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function insertOrUpdatePropertiesToIndex($properties, $identifier) {
121121
$statementArgumentNumber = 1;
122122
foreach ($properties as $propertyValue) {
123123
if (is_array($propertyValue)) {
124-
$propertyValue = implode(',', $propertyValue);
124+
$propertyValue = $this->implodeRecursive(',', $propertyValue);
125125
}
126126
$preparedStatement->bindValue($this->preparedStatementArgumentName($statementArgumentNumber), $propertyValue);
127127
$statementArgumentNumber++;
@@ -311,4 +311,21 @@ protected function adjustIndexToGivenProperties(array $propertyNames) {
311311
}
312312
}
313313
}
314+
315+
/**
316+
* @param string $glue
317+
* @param array $pieces
318+
* @return string
319+
*/
320+
private function implodeRecursive($glue, $pieces) {
321+
$stringValue = '';
322+
array_walk_recursive($pieces,
323+
function($cellValue) use (&$stringValue, $glue) {
324+
$stringValue .= $cellValue . $glue;
325+
});
326+
327+
// Remove trailing glue
328+
$stringValue = substr($stringValue, 0, 0 - strlen($glue));
329+
return $stringValue;
330+
}
314331
}

0 commit comments

Comments
 (0)