| Total Complexity | 4 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Mysql extends QueryBase |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var $instance |
||
|
|
|||
| 11 | */ |
||
| 12 | private static $instance; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var $connection |
||
| 16 | */ |
||
| 17 | protected $connection; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var mixed |
||
| 21 | */ |
||
| 22 | protected $config; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Mysql constructor. |
||
| 26 | * @param $config |
||
| 27 | */ |
||
| 28 | public function __construct($config) |
||
| 29 | { |
||
| 30 | $this->config = $config; |
||
| 31 | |||
| 32 | if(is_null(self::$instance)){ |
||
| 33 | |||
| 34 | //get pdo dsn |
||
| 35 | $dsn=''.$config['driver'].':host='.$config['host'].';dbname='.$config['database'].''; |
||
| 36 | $this->connection = new \PDO($dsn, $config['user'], $config['password']); |
||
| 37 | $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
||
| 38 | |||
| 39 | self::$instance=true; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * get config |
||
| 45 | * |
||
| 46 | * @return mixed |
||
| 47 | */ |
||
| 48 | public function getConfig() |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return \PDO |
||
| 55 | */ |
||
| 56 | public function getConnection() |
||
| 61 | } |