diff --git a/src/db/CapacitorStorage.php b/src/db/CapacitorStorage.php index 85a0d39..d808656 100644 --- a/src/db/CapacitorStorage.php +++ b/src/db/CapacitorStorage.php @@ -2,6 +2,7 @@ namespace nur\sery\db; use nur\sery\cl; +use nur\sery\file\_File; use nur\sery\php\func; use nur\sery\ValueException; @@ -69,10 +70,8 @@ abstract class CapacitorStorage { $row[$sumCol] = $sum[$sumCol]; } } - } else { - if (array_key_exists($key, $values)) { - $row[$col] = $values[$key]; - } + } elseif (array_key_exists($key, $values)) { + $row[$col] = $values[$key]; } } return $row; @@ -318,13 +317,39 @@ EOT; return $this->_discharge($this->getChannel($channel), $reset); } + protected function _convertValue2row(CapacitorChannel $channel, array $filter, array $cols): array { + $index = 0; + $fixed = []; + foreach ($filter as $key => $value) { + if ($key === $index) { + $index++; + if (is_array($value)) { + $value = $this->_convertValue2row($channel, $value, $cols); + } + $fixed[] = $value; + } else { + $col = "${key}__"; + if (array_key_exists($col, $cols)) { + # colonne sérialisée + $fixed[$col] = $channel->serialize($value); + } else { + $fixed[$key] = $value; + } + } + } + return $fixed; + } + protected function verifixFilter(CapacitorChannel $channel, &$filter): void { if ($filter !== null && !is_array($filter)) { $id = $filter; $channel->verifixId($id); $filter = ["id_" => $id]; } - $filter = $this->serialize($channel, $filter); + $cols = $this->ColumnDefinitions($channel); + if ($filter !== null) { + $filter = $this->_convertValue2row($channel, $filter, $cols); + } } /** indiquer le nombre d'éléments du canal spécifié */