| Conditions | 6 |
| Paths | 18 |
| Total Lines | 35 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | public function getConnection() |
||
| 35 | { |
||
| 36 | try { |
||
| 37 | if ($this->instancia == null) { |
||
| 38 | |||
| 39 | $json = new JsonReader(BASE_DIR . self::PATH_CONFIG_FILE); |
||
| 40 | |||
| 41 | if (!empty(glob(dirname(__DIR__, 4) . self::PATH_CONFIG_FILE )[0])) { |
||
| 42 | $json = new JsonReader(glob(dirname(__DIR__, 4) . PATH_CONFIG_FILE)[0]); |
||
| 43 | } |
||
| 44 | |||
| 45 | $json= $json->read(); |
||
| 46 | try { |
||
| 47 | |||
| 48 | $connectionCache = $json->phiber->link->connection_cache == 1 ? true : false; |
||
| 49 | |||
| 50 | $this->instancia = new PDO( |
||
| 51 | $json->phiber->link->url, |
||
| 52 | $json->phiber->link->user, |
||
| 53 | $json->phiber->link->password, |
||
| 54 | array( |
||
| 55 | PDO::ATTR_PERSISTENT => $connectionCache |
||
| 56 | ) |
||
| 57 | ); |
||
| 58 | } catch (PhiberException $e) { |
||
| 59 | throw new PhiberException(new Internationalization("database_connection_error")); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | return $this->instancia; |
||
| 64 | |||
| 65 | } catch (PhiberException $e) { |
||
| 66 | throw new PhiberException(new Internationalization("database_connection_error")); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | } |