- $db_map = array('pgsql' => 'postgres', 'mysqli' => 'mysql');
- $engine = isset($db_map[$DB->db_provider]) ? $db_map[$DB->db_provider] : $DB->db_provider;
+ $engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
+
+ // read schema file from /SQL/*
+ $fname = INSTALL_PATH . "SQL/$engine.initial.sql";
+ if ($sql = @file_get_contents($fname)) {
+ $this->exec_sql($sql, $DB);
+ }
+ else {
+ $this->fail('DB Schema', "Cannot read the schema file: $fname");
+ return false;
+ }
+
+ if ($err = $this->get_error()) {
+ $this->fail('DB Schema', "Error creating database schema: $err");
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Update database with SQL statements from SQL/*.update.sql
+ *
+ * @param object rcube_db Database connection
+ * @param string Version to update from
+ * @return boolen True on success, False on error
+ */
+ function update_db($DB, $version)
+ {
+ $version = strtolower($version);
+ $engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;