- WIP on SQLite Adapter and migration
This commit is contained in:
1 parent
cee978ecfd
commit
9514a46ae7
14 files changed
+98
-40
No files matched your search
+12
-2
@@ -34,7 +34,6 @@ trait EntityTrait {
|
||||
$entityResolver = $this->resolveEntity();
|
||||
|
||||
foreach($dataset as $key => $value) {
|
||||
|
||||
$field = $entityResolver->field(strtolower($key), EntityResolver::KEY_COLUMN_NAME, false) ?? null;
|
||||
$field ??= $entityResolver->field(strtolower($key), EntityResolver::KEY_LC_ENTITY_NAME, false);
|
||||
|
||||
@@ -51,7 +50,18 @@ trait EntityTrait {
|
||||
}
|
||||
elseif ( $field['type'] === 'array' ) {
|
||||
if ( is_string($value)) {
|
||||
$this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true);
|
||||
if (substr($value, 0, 1) === "a") {
|
||||
$this->{$field['name']} = unserialize($value);
|
||||
}
|
||||
else {
|
||||
$data = json_decode($value, true);
|
||||
|
||||
if (json_last_error() !== \JSON_ERROR_NONE) {
|
||||
throw new \Exception(sprintf("JSON error while decoding in EntityTrait : '%s' given %s", json_last_error_msg(), $value));
|
||||
}
|
||||
|
||||
$this->{$field['name']} = $data;
|
||||
}
|
||||
}
|
||||
elseif ( is_array($value) ) {
|
||||
$this->{$field['name']} = $value;
|
||||
|
||||
Reference in new issue
Block a user