contaoblackforest / contao-doctrine-dbal-driver
Database Driver using Doctrine DBAL for Contao Open Source CMS
Installs: 16
Dependents: 0
Suggesters: 2
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Type:contao-module
Requires
- php: >=5.3
- contao-community-alliance/composer-plugin: ~2.0
- contao/core: >=3.2,<3.4-dev
- doctrine/dbal: 2.4.*
Replaces
- dev-contao-3.2 / 3.2.x-dev
- 3.2.2
- 3.2.1
- 3.2.0
- dev-contao-3.1 / 3.1.x-dev
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1
- dev-contao-3.0 / 3.0.x-dev
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0
- dev-contao-2.11 / 2.11.x-dev
- 2.11.11
- 2.11.10
- 2.11.9
- 2.11.8
- 2.11.7
- 2.11.6
- 2.11.5
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11
This package is auto-updated.
Last update: 2024-10-29 04:47:21 UTC
README
To use this database driver, change the driver in your system/config/localconfig.php
:
$GLOBALS['TL_CONFIG']['dbDriver'] = 'DoctrineMySQL';
Configure caching
By default, the driver use an array cache (equivalent to contao).
But the caching can be configured with $GLOBALS['TL_CONFIG']['dbCache']
, $GLOBALS['TL_CONFIG']['dbCacheTTL']
and $GLOBALS['TL_CONFIG']['dbCacheName']
.
$GLOBALS['TL_CONFIG']['dbCache']
define the caching mechanism, possible values are:
$GLOBALS['TL_CONFIG']['dbCacheTTL']
is an integer value, that define the time to live
(default value is 1 second for backend and 15 second for frontend).
$GLOBALS['TL_CONFIG']['dbCacheName']
is a string for uniq identify cache entries. This is useful if you have a shared cache like memcache
(default value is md5(/absolute/path/to/bit3/contao-doctrine-dbal-driver/src/Contao/Doctrine/Driver/MySQL/Statement.php)
).
Different caching in frontend and backend
You can add _FE
or _BE
to each cache config key, to define different caching in frontend and backend.
For example $GLOBALS['TL_CONFIG']['dbCache_FE']
define the frontend caching mechanism
and $GLOBALS['TL_CONFIG']['dbCacheTTL_BE']
define the backend caching time to live.
Accessing the doctrine dbal connection
If you have installed bit3/contao-doctrine-dbal, you should use the dependency injection container:
class MyClass { public function myFunc() { global $container; /** @var \Doctrine\DBAL\Connection $connection */ $connection = $container['doctrine.connection.default']; $connection->query('...'); } }
Alternatively you can get the connection from the database instance:
class MyClass { public function myFunc() { /** @var \Doctrine\DBAL\Connection $connection */ $connection = Database::getInstance()->getConnection(); } }