|
6 | 6 | */ |
7 | 7 | require __DIR__ . '/../vendor/autoload.php'; |
8 | 8 |
|
9 | | -use Crate\DBAL\Platforms\CratePlatform4; |
| 9 | +use Crate\DBAL\Driver\PDOCrate\Driver as CrateDBDriver; |
10 | 10 | use Crate\DBAL\Types\MapType; |
11 | 11 | use Doctrine\DBAL\DriverManager; |
12 | 12 | use Doctrine\DBAL\Exception\TableNotFoundException; |
|
16 | 16 | use Doctrine\DBAL\Tools\DsnParser; |
17 | 17 | use Doctrine\DBAL\Types\Type; |
18 | 18 |
|
19 | | -// Register driver. |
20 | | -$dsnParser = new DsnParser(array('crate' => 'Crate\DBAL\Driver\PDOCrate\Driver')); |
21 | 19 |
|
22 | | -// Compute connection options. |
23 | | -$options = $dsnParser->parse('crate://crate:crate@localhost:4200/'); |
24 | | - |
25 | | -// Select platform. It is highly encouraged to use the platform |
26 | | -// class that matches your database vendor and version best. |
| 20 | +// Register driver and select platform. |
| 21 | +// Because DBAL can't connect to the database to determine its version dynamically, |
| 22 | +// it is the obligation of the user to provide the CrateDB version number. |
| 23 | +// Remark: Please let us know if you find a way how to set up more ergonomically. |
27 | 24 | // https://www.doctrine-project.org/projects/doctrine-dbal/en/3.10/reference/platforms.html |
28 | | -$options['platform'] = new CratePlatform4(); |
| 25 | +$driver = new CrateDBDriver(); |
| 26 | +$dsnParser = new DsnParser(["crate" => $driver::class]); |
| 27 | +$driver->createDatabasePlatformForVersion('6.0.0'); |
| 28 | + |
| 29 | +// Create connection options from data source URL. |
| 30 | +$options = $dsnParser->parse('crate://crate:crate@localhost:4200/'); |
29 | 31 |
|
30 | 32 | // Connect to database. |
31 | 33 | $connection = DriverManager::getConnection($options); |
|
0 commit comments