Skip to content

Commit

Permalink
Merge pull request #26 from dimitriadisg/patch-1
Browse files Browse the repository at this point in the history
BUGFIX: Fix SqLiteIndex for multi-dimensional arrays
  • Loading branch information
kitsunet authored Jan 24, 2020
2 parents ab02948 + 7b0be6d commit a664e6c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Classes/Domain/Service/SqLiteIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function insertOrUpdatePropertiesToIndex($properties, $identifier) {
$statementArgumentNumber = 1;
foreach ($properties as $propertyValue) {
if (is_array($propertyValue)) {
$propertyValue = implode(',', $propertyValue);
$propertyValue = $this->implodeRecursive(',', $propertyValue);
}
$preparedStatement->bindValue($this->preparedStatementArgumentName($statementArgumentNumber), $propertyValue);
$statementArgumentNumber++;
Expand Down Expand Up @@ -311,4 +311,21 @@ protected function adjustIndexToGivenProperties(array $propertyNames) {
}
}
}

/**
* @param string $glue
* @param array $pieces
* @return string
*/
private function implodeRecursive($glue, $pieces) {
$stringValue = '';
array_walk_recursive($pieces,
function($cellValue) use (&$stringValue, $glue) {
$stringValue .= $cellValue . $glue;
});

// Remove trailing glue
$stringValue = substr($stringValue, 0, 0 - strlen($glue));
return $stringValue;
}
}

0 comments on commit a664e6c

Please sign in to comment.