diff options
Diffstat (limited to 'src/application/mystic/forum')
-rw-r--r-- | src/application/mystic/forum/Database.php | 5 | ||||
-rw-r--r-- | src/application/mystic/forum/orm/User.php | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/application/mystic/forum/Database.php b/src/application/mystic/forum/Database.php index 7a417be..632b2d6 100644 --- a/src/application/mystic/forum/Database.php +++ b/src/application/mystic/forum/Database.php @@ -319,8 +319,11 @@ class Database { $tableName = self::getTableName($entityClassName); $reflClass = new ReflectionClass($entityClassName); $cols = self::getColumns($reflClass); + $values = ArrayUtils::fill(fn($i) => null, count($cols)); + foreach (self::getColumnValues($entity, $cols) as $i => $value) + $values[$i] = $value; $query = "INSERT INTO $tableName VALUES (" . implode(",", ArrayUtils::fill(fn($i) => "$" . ($i + 1), count($cols))) . ");"; - $result = \pg_query_params($this->connection, $query, self::getColumnValues($entity, $cols)); + $result = \pg_query_params($this->connection, $query, $values); if ($result === false) throw new \RuntimeException("Insert failed: " . \pg_last_error($this->connection)); \pg_free_result($result); diff --git a/src/application/mystic/forum/orm/User.php b/src/application/mystic/forum/orm/User.php index 868f385..a1414c3 100644 --- a/src/application/mystic/forum/orm/User.php +++ b/src/application/mystic/forum/orm/User.php @@ -12,8 +12,7 @@ use mystic\forum\attributes\Unique; class User extends Entity { public const SUPERUSER_ID = "SUPERUSER"; - #[PrimaryKey] - public string $id; + #[PrimaryKey] public string $id; #[Unique] public string $name; public string $displayName; #[Unique] public string $email; |