/** * Initializes database connection * * @param $pixie * @param string $config Name of the connection to initialize * @return \PHPixie\DB\PDOV\Connection */ public function __construct($pixie, $config) { parent::__construct($pixie, $config); $this->conn = new \PDO($pixie->config->get("db.{$config}.connection"), $pixie->config->get("db.{$config}.user", ''), $pixie->config->get("db.{$config}.password", '')); $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $this->db_type = strtolower(str_replace('PDO_', '', $this->conn->getAttribute(\PDO::ATTR_DRIVER_NAME))); if ($this->db_type != 'sqlite') { $this->conn->exec("SET NAMES utf8"); } }
/** * Initializes database connection * * @param string $config Name of the connection to initialize * @return void */ public function __construct($pixie, $config) { parent::__construct($pixie, $config); $this->conn = mysqli_connect($pixie->config->get("db.{$config}.host", 'localhost'), $pixie->config->get("db.{$config}.user", ''), $pixie->config->get("db.{$config}.password", ''), $pixie->config->get("db.{$config}.db")); $this->conn->set_charset("utf8"); }