PostgreSQL Support (#4486)
Co-authored-by: Matthew Penner <matthew@pterodactyl.io>
This commit is contained in:
parent
21613fa602
commit
3bf5a71802
223 changed files with 912 additions and 1052 deletions
|
@ -2,9 +2,12 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use PDO;
|
||||
use RuntimeException;
|
||||
use Illuminate\Http\Request;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Pterodactyl\Repositories\Repository;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
@ -271,7 +274,17 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
return sprintf('(%s)', $grammar->parameterize($record));
|
||||
})->implode(', ');
|
||||
|
||||
$statement = "insert ignore into $table ($columns) values $parameters";
|
||||
$driver = DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
switch ($driver) {
|
||||
case 'mysql':
|
||||
$statement = "insert ignore into $table ($columns) values $parameters";
|
||||
break;
|
||||
case 'pgsql':
|
||||
$statement = "insert into $table ($columns) values $parameters on conflict do nothing";
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported database driver \"$driver\" for insert ignore.");
|
||||
}
|
||||
|
||||
return $this->getBuilder()->getConnection()->statement($statement, $bindings);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue