diff --git a/Database/AbstractDatabase.php b/Database/AbstractDatabase.php index c54c893c7..e724ca224 100644 --- a/Database/AbstractDatabase.php +++ b/Database/AbstractDatabase.php @@ -133,9 +133,9 @@ final public function prepareInsert($table, array $values) { $query[] = "INSERT INTO "; $query[] = $table; - $query[] = " ("; - $query[] = implode(", ", array_keys($values)); - $query[] = ") VALUES ("; + $query[] = " (`"; + $query[] = implode("`, `", array_keys($values)); + $query[] = "`) VALUES ("; $query[] = implode(", ", array_values($values)); $query[] = ")"; @@ -155,7 +155,7 @@ final public function prepareUpdate($table, array $values) { // Initialize the SET. $set = []; foreach ($values as $k => $v) { - $set[] = $k . " = " . $v; + $set[] = "`" . $k . "` = " . $v; } // Initialize the query. diff --git a/Tests/Database/Microsoft/MicrosoftAccessDatabaseTest.php b/Tests/Database/Microsoft/MicrosoftAccessDatabaseTest.php index 1c6bd4b5c..5e649ab87 100644 --- a/Tests/Database/Microsoft/MicrosoftAccessDatabaseTest.php +++ b/Tests/Database/Microsoft/MicrosoftAccessDatabaseTest.php @@ -81,7 +81,7 @@ public function testPrepareInsert() { $obj = new MicrosoftAccessDatabase(); $arg = ["field1" => 1, "field2" => "'value2'", "field3" => "'value3'"]; - $res = "INSERT INTO table (field1, field2, field3) VALUES (1, 'value2', 'value3')"; + $res = "INSERT INTO table (`field1`, `field2`, `field3`) VALUES (1, 'value2', 'value3')"; $this->assertEquals($res, $obj->prepareInsert("table", $arg)); } @@ -95,7 +95,7 @@ public function testPrepareUpdate() { $obj = new MicrosoftAccessDatabase(); $arg = ["field1" => 1, "field2" => "'value2'", "field3" => "'value3'"]; - $res = "UPDATE table SET field1 = 1, field2 = 'value2', field3 = 'value3'"; + $res = "UPDATE table SET `field1` = 1, `field2` = 'value2', `field3` = 'value3'"; $this->assertEquals($res, $obj->prepareUpdate("table", $arg)); }