23 lines
481 B
PHP
23 lines
481 B
PHP
|
<?php
|
||
|
|
||
|
ini_set('display_errors',1);
|
||
|
ini_set('display_startup_errors',1);
|
||
|
error_reporting(-1);
|
||
|
|
||
|
try{
|
||
|
|
||
|
// create instance with arguments + 10sec timeout
|
||
|
$pdo = new PDO('mysql:host=mariadb;dbname=db1', 'php', 'php-password', [PDO::ATTR_TIMEOUT => 10]);
|
||
|
|
||
|
// On signale que tout s'est bien passe
|
||
|
echo "Connected to database";
|
||
|
|
||
|
}catch(Exception $e){
|
||
|
// On signale qu'il y a une erreur
|
||
|
echo "Cannot connect to database";
|
||
|
|
||
|
echo "msg: ".$e->getMessage();
|
||
|
}
|
||
|
|
||
|
|
||
|
phpinfo();
|