Created
October 7, 2016 09:25
-
-
Save zillingen/7530a92b46dff1f9dd79063eb542cff1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*---------------------------------------- | |
| Инструкции и примеры по работе с PDO | | |
----------------------------------------*/ | |
/** | |
* Подключение к базе данных | |
*/ | |
try { | |
$db = new PDO('mysql:host=localhost;dbname=database;charset=UTF8','user','password'); | |
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
} catch (PDOException $e) { | |
echo "<div class=\"container\"> | |
<div class=\"alert alert-danger\" role=\"alert\"> | |
Can't connect to DB: " . $e->getMessage() . | |
"</div> | |
</div>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment