db_name = $name; $this->host = Settings::getDatabaseHostname(); } /** * Get the database connection. */ public function getConnection() { if ($this->cnx == null) { try { $this->cnx = new \PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password, array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); } catch(PDOException $e){ throw new Exception($e->getMessage()); } } return $this->cnx; } /** * Get the database connection (admin). */ public function getAdminConnection() { if ($this->cnx == null) { try { $this->cnx = new \PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name."_admin", $this->username, $this->password, array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); } catch(PDOException $e){ throw new Exception($e->getMessage()); } } return $this->cnx; } /** * Get the database connection (audit). */ public function getAuditConnection() { if ($this->cnx == null) { try { $this->cnx = new \PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name."_audit", $this->username, $this->password, array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); } catch(PDOException $e){ throw new Exception($e->getMessage()); } } return $this->cnx; } } } ?>