Skip to content

Commit 8df8f90

Browse files
committed
Documentation: Make example program independent of CratePlatform4
Does it increase usability?
1 parent 6425cc4 commit 8df8f90

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

examples/objects.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
require __DIR__ . '/../vendor/autoload.php';
88

9-
use Crate\DBAL\Platforms\CratePlatform4;
9+
use Crate\DBAL\Driver\PDOCrate\Driver as CrateDBDriver;
1010
use Crate\DBAL\Types\MapType;
1111
use Doctrine\DBAL\DriverManager;
1212
use Doctrine\DBAL\Exception\TableNotFoundException;
@@ -16,16 +16,18 @@
1616
use Doctrine\DBAL\Tools\DsnParser;
1717
use Doctrine\DBAL\Types\Type;
1818

19-
// Register driver.
20-
$dsnParser = new DsnParser(array('crate' => 'Crate\DBAL\Driver\PDOCrate\Driver'));
2119

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.
2724
// 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/');
2931

3032
// Connect to database.
3133
$connection = DriverManager::getConnection($options);

0 commit comments

Comments
 (0)