Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Core;
- abstract class Model {
- protected static function getDB() {
- static $db = null;
- if($db === null){
- $host = 'localhost';
- $dbname = 'test';
- $username = 'root';
- $password = '';
- try{
- $db = new \PDO("mysql:host={$host};dbname={$dbname};", $username, $password, array(
- \PDO::ATTR_PERSISTENT => true));
- return $db;
- }catch (\PDOException $e){
- echo $e->getMessage();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement