diff --git a/src/Database/Connections/MySqlConnection.php b/src/Database/Connections/MySqlConnection.php index 317ef232b..24b87b664 100644 --- a/src/Database/Connections/MySqlConnection.php +++ b/src/Database/Connections/MySqlConnection.php @@ -31,7 +31,12 @@ public function isMaria() */ protected function getDefaultQueryGrammar() { - return $this->withTablePrefix(new QueryGrammar); + $grammar = new QueryGrammar; + if (method_exists($grammar, 'setConnection')) { + $grammar->setConnection($this); + } + + return $this->withTablePrefix($grammar); } /** @@ -55,7 +60,12 @@ public function getSchemaBuilder() */ protected function getDefaultSchemaGrammar() { - return $this->withTablePrefix(new SchemaGrammar); + $grammar = new SchemaGrammar; + if (method_exists($grammar, 'setConnection')) { + $grammar->setConnection($this); + } + + return $this->withTablePrefix($grammar); } /**