| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 27 | public static function get() |
||
| 28 | { |
||
| 29 | if (!self::$con) { |
||
| 30 | self::$con = new \PDO('mysql:host=localhost; dbname='.Credentials::get('database'), |
||
| 31 | Credentials::get('username'), |
||
| 32 | Credentials::get('password') |
||
| 33 | ); |
||
| 34 | self::$con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); |
||
| 35 | // which tells PDO to disable emulated prepared statements and use real prepared statements. |
||
| 36 | // This makes sure the statement and the values aren't parsed by PHP before sending it to the |
||
| 37 | // MySQL server (giving a possible attacker no chance to inject malicious SQL). |
||
| 38 | self::$con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
||
| 39 | } |
||
| 40 | |||
| 41 | return self::$con; |
||
| 42 | } |
||
| 48 |