PHP code example of contaoblackforest / contao-doctrine-dbal-driver

1. Go to this page and download the library: Download contaoblackforest/contao-doctrine-dbal-driver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

contaoblackforest / contao-doctrine-dbal-driver example snippets


$GLOBALS['TL_CONFIG']['dbDriver'] = 'DoctrineMySQL';

class MyClass
{
	public function myFunc()
	{
		global $container;
		/** @var \Doctrine\DBAL\Connection $connection */
		$connection = $container['doctrine.connection.default'];

		$connection->query('...');
	}
}

class MyClass
{
	public function myFunc()
	{
		/** @var \Doctrine\DBAL\Connection $connection */
		$connection = Database::getInstance()->getConnection();
	}
}