diff options
Diffstat (limited to 'src/model/doctrine-bootstrap.php')
| -rw-r--r-- | src/model/doctrine-bootstrap.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/model/doctrine-bootstrap.php b/src/model/doctrine-bootstrap.php new file mode 100644 index 0000000..029b1b1 --- /dev/null +++ b/src/model/doctrine-bootstrap.php | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/doctrine-bootstrap.php | ||
| 3 | |||
| 4 | use Doctrine\DBAL\DriverManager; | ||
| 5 | use Doctrine\ORM\EntityManager; | ||
| 6 | use Doctrine\ORM\ORMSetup; | ||
| 7 | |||
| 8 | require_once "vendor/autoload.php"; | ||
| 9 | |||
| 10 | // Create a simple "default" Doctrine ORM configuration for Attributes | ||
| 11 | $config = ORMSetup::createAttributeMetadataConfiguration( | ||
| 12 | //paths: array(__DIR__.'/entities'), | ||
| 13 | paths: array('src/model/entities'), | ||
| 14 | isDevMode: true, | ||
| 15 | ); | ||
| 16 | // or if you prefer XML | ||
| 17 | // $config = ORMSetup::createXMLMetadataConfiguration( | ||
| 18 | // paths: array(__DIR__."/config/xml"), | ||
| 19 | // isDevMode: true, | ||
| 20 | //); | ||
| 21 | |||
| 22 | // configuring the database connection | ||
| 23 | $connection = DriverManager::getConnection([ | ||
| 24 | 'driver' => 'pdo_sqlite', | ||
| 25 | //'path' => __DIR__ . '/../../data/' . Config::$db_name . '.sqlite', | ||
| 26 | 'path' => 'data/' . Config::$db_name . '.sqlite', | ||
| 27 | ], $config); | ||
| 28 | |||
| 29 | // obtaining the entity manager | ||
| 30 | $entityManager = new EntityManager($connection, $config); | ||
| 31 | |||
