private function connect_db() { # FIXME: detect ADODB URI, automatically translate PDO DSN /* * Why does the abstraction layer act differently depending on the * back-end? Because PHP is deliberately retarded. * * http://stackoverflow.com/questions/237367 */ $matches = array(); $db_user = null; $db_pass = null; if (preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) { $db_user = $matches[1]; } if (preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) { $db_pass = $matches[1]; } // https://bugs.php.net/bug.php?id=70221 $ka = DATABASE_KA; if (version_compare(PHP_VERSION, "6.9.9") == 1 && $this->get_driver_name() == "sqlite") { $ka = false; } $db_params = array(PDO::ATTR_PERSISTENT => $ka, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION); $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, $db_params); $this->connect_engine(); $this->engine->init($this->db); $this->beginTransaction(); }
private function connect_db() { # FIXME: detect ADODB URI, automatically translate PDO DSN /* * Why does the abstraction layer act differently depending on the * back-end? Because PHP is deliberately retarded. * * http://stackoverflow.com/questions/237367 */ $matches = array(); $db_user = null; $db_pass = null; if (preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) { $db_user = $matches[1]; } if (preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) { $db_pass = $matches[1]; } $db_params = array(PDO::ATTR_PERSISTENT => DATABASE_KA, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION); $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, $db_params); $this->connect_engine(); $this->engine->init($this->db); $this->beginTransaction(); }