diff options
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); |