Skip to content

Commit 3fc44da

Browse files
authored
Merge pull request #105 from AdairHomes/master
Determine database driver from model
2 parents 98cd248 + 11c2948 commit 3fc44da

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Batch.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public function update(Model $table, array $values, string $index = null, bool $
6565
$index = $table->getKeyName();
6666
}
6767

68-
$connection = config('database.default');
69-
$driver = config("database.connections.{$connection}.driver");
68+
$driver = $table->getConnection()->getDriverName();
7069

7170
foreach ($values as $key => $val) {
7271
$ids[] = $val[$index];
@@ -174,8 +173,7 @@ public function updateWithTwoIndex(Model $table, array $values, string $index =
174173
{
175174
$final = [];
176175
$ids = [];
177-
$connection = config('database.default');
178-
$driver = config("database.connections.{$connection}.driver");
176+
$driver = $table->getConnection()->getDriverName();
179177

180178
if (!count($values)) {
181179
return false;
@@ -320,8 +318,7 @@ public function insert(Model $table, array $columns, array $values, int $batchSi
320318
}
321319
}
322320

323-
$connection = config('database.default');
324-
$driver = config("database.connections.{$connection}.driver");
321+
$driver = $table->getConnection()->getDriverName();
325322

326323
if (Common::disableBacktick($driver)) {
327324
foreach ($columns as $key => $column) {

0 commit comments

Comments
 (0)