Use DB_CONNECTION string instead of SQLITE_DB_NAME
This commit is contained in:
parent
0f61dd1bc6
commit
0372f86cd2
@ -1 +1 @@
|
|||||||
SQLITE_DB_NAME=app.db
|
DB_CONNECTION=sqlite3://app.db
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use DI\Container;
|
use DI\Container;
|
||||||
use Doctrine\DBAL\DriverManager;
|
use Doctrine\DBAL\DriverManager;
|
||||||
|
use Doctrine\DBAL\Tools\DsnParser;
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\ORMSetup;
|
use Doctrine\ORM\ORMSetup;
|
||||||
@ -48,10 +49,10 @@ $container->set(EntityManager::class, static function() {
|
|||||||
isDevMode: true,
|
isDevMode: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$connection = DriverManager::getConnection([
|
$dsnParser = new DsnParser();
|
||||||
'driver' => 'pdo_sqlite',
|
$params = $dsnParser->parse($_ENV["DB_CONNECTION"]);
|
||||||
'path' => __DIR__ . '/../' . $_ENV["SQLITE_DB_NAME"],
|
|
||||||
], $config);
|
$connection = DriverManager::getConnection($params, $config);
|
||||||
|
|
||||||
$connection->executeQuery("PRAGMA foreign_keys = ON");
|
$connection->executeQuery("PRAGMA foreign_keys = ON");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user