diff options
author | Jonas Kohl | 2024-10-19 12:38:39 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-10-19 12:38:39 +0200 |
commit | 3c8f4f695f1b9ec7a188b85e0ce38bc69c697008 (patch) | |
tree | 918281d3471e70f85abe6946357a7737186187e5 /src/application/mystic/forum/Database.php | |
parent | 04b50a77c84e3e92a2ca2fd0e6d239d974429c5b (diff) |
Small ORM fixes
Diffstat (limited to 'src/application/mystic/forum/Database.php')
-rw-r--r-- | src/application/mystic/forum/Database.php | 5 |
1 files changed, 4 insertions, 1 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); |