Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 12 |
DbalFactory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
6.00 | |
0.00% |
0 / 12 |
getPdoOptions | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 8 |
|||
mysql | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
<?php | |
namespace Puyo\Db; | |
class DbalFactory | |
{ | |
public static function getPdoOptions() { | |
return [ | |
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, | |
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, | |
\PDO::ATTR_AUTOCOMMIT => false, | |
\PDO::ATTR_EMULATE_PREPARES => true, | |
\PDO::ATTR_CASE => \PDO::CASE_LOWER, | |
]; | |
} | |
public static function mysql($host, $dbname, $user, $pw, $charset=null) { | |
$strDsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', $host, $dbname, $charset); | |
$pdo = new \PDO($strDsn, $user, $pw, self::getPdoOptions()); | |
return new Dbal($pdo); | |
} | |
} |