×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: user165e7
Added: Mar 22, 2018 3:08 PM
Views: 2934
Tags: no tags
  1. <?php
  2.  
  3. class Db
  4. {
  5.  
  6.                 public static function getConnection()
  7.                 {
  8.                         $paramsPath = ROOT . '/config/db_params.php';
  9.                         $params = include($paramsPath);
  10.  
  11.  
  12.                         $dsn = "mysql:host={$params['host']};dbname={$params['dbname']}";
  13.                         $db = new PDO($dsn, $params['user'], $params['password']);
  14.  
  15.                         return $db;
  16.                 }
  17. }