Skip to content

Commit

Permalink
Fix query for access
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Mar 20, 2018
1 parent 54383e5 commit ea3df8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Database/AbstractDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = ")";

Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Database/Microsoft/MicrosoftAccessDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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));
}

Expand Down

0 comments on commit ea3df8a

Please sign in to comment.