Getested in Contao 5
config.yml
HTML-Code:
doctrine:
dbal:
connections:
default:
options:
1002: "SET SESSION sql_mode=(SELECT CONCAT(@@sql_mode, ',TRADITIONAL'))"
second:
driver: pdo_mysql
host: '%second_database_host%'
port: '%second_database_port%'
dbname: '%second_database_name%'
user: '%second_database_user%'
password: '%second_database_password%'
charset: UTF8
parameters.yml
HTML-Code:
parameters:
second_database_host: localhost
second_database_port: null
second_database_name: dbname
second_database_user: username
second_database_password: password
Testen
PHP-Code:
$db2 = System::getContainer()->get('doctrine')->getConnection('second');
$db2res = $db2->prepare("SELECT * FROM tl_calendar")->execute();
echo '<pre>';
var_dump($db2res->fetchAllAssociative());
exit;