reorganisation init
[mtweb] / mw / env / modules / mw_env_sgbds.php
index dfdb74f..97a280a 100644 (file)
       return $this->sgbds;
     }
 
+    public function load_sgbd(){
+      if(($data = $this->data()) && $this->bdd("sgbd")){
+        $sgbd_impl_file = $this->path("mw_dir")."env/sgbd/mw_".$this->bdd("sgbd").".php";
+        if(!file_exists($sgbd_impl_file)){
+          $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
+        }
+        $sgbd_impl = "mw_".$this->bdd("sgbd");
+        if(!class_exists($sgbd_impl)) require_once $sgbd_impl_file;
+        if(!class_exists($sgbd_impl)){
+          $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
+        }
+        $sgbd = new $sgbd_impl(
+          $this,
+          array(
+            "host" => $this->bdd("host"),
+            "base" => $this->bdd("base"),
+            "user" => $this->bdd("user"),
+            "password" => $this->bdd("password")
+          )
+        );
+        if(!$sgbd->extention_ok()){
+          $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas installée", true);
+        }
+        $data->set_sgbd($sgbd);
+      }
+    }
+
   }
 
   // -------------------------------------------------------------------------------------------