Total Complexity | 6 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
16 | class ActiveRecord |
||
17 | { |
||
18 | private static $dbh; |
||
19 | private static $sth; |
||
20 | private static $config; |
||
|
|||
21 | |||
22 | public static function connection(string $dsn, string $user, string $pass): void |
||
23 | { |
||
24 | ActiveRecord::$dbh = new PDO($dsn, $user, $pass); |
||
25 | ActiveRecord::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
26 | } |
||
27 | |||
28 | private static function getConn(): PDO |
||
29 | { |
||
30 | return ActiveRecord::$dbh; |
||
31 | } |
||
32 | |||
33 | private static function prepare(string $query): PDOStatement |
||
36 | } |
||
37 | |||
38 | protected static function execute(string $query, array $parameters = []): ?PDOStatement |
||
39 | { |
||
40 | if (ActiveRecord::prepare($query)->execute($parameters)) { |
||
41 | return ActiveRecord::$sth; |
||
42 | } |
||
43 | return null; |
||
44 | } |
||
45 | |||
46 | protected static function exec(string $sql): int |
||
49 | } |
||
50 | } |
||
51 |