summaryrefslogtreecommitdiff
path: root/src/application/mystic/forum/Database.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/application/mystic/forum/Database.php')
-rw-r--r--src/application/mystic/forum/Database.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/application/mystic/forum/Database.php b/src/application/mystic/forum/Database.php
index 8ebc36b..7a417be 100644
--- a/src/application/mystic/forum/Database.php
+++ b/src/application/mystic/forum/Database.php
@@ -142,6 +142,7 @@ class Database {
return "text";
case "object":
case "array":
+ return "jsonb";
case "iterable":
case "callable":
case "mixed":
@@ -241,8 +242,10 @@ class Database {
return strval($value);
elseif (is_a($value, \DateTimeInterface::class))
return $value->format("c");
+ elseif (is_array($value) || is_object($value))
+ return json_encode($value, JSON_UNESCAPED_SLASHES);
else
- throw new \RuntimeException("Don't know how to stringify " . is_object($value) ? get_class($value) : gettype($value));
+ throw new \RuntimeException("Don't know how to stringify " . ((is_object($value) && !is_array($value)) ? get_class($value) : gettype($value)));
}
private static function assignValue(Entity &$entity, array $colProps, ?string $value): void {
@@ -285,7 +288,11 @@ class Database {
}
break;
case "object":
+ $typedValue = json_decode($value);
+ break;
case "array":
+ $typedValue = json_decode($value, true);
+ break;
case "iterable":
case "callable":
case "mixed":