implementation sgbd herite de mw_sgbd
[mtweb] / mw / app / data / impl / mw_pdo_sqlite.php
index 8fd7deb..918bc8a 100644 (file)
@@ -1,38 +1,28 @@
 <?php
 
-  class mw_pdo_sqlite{
-
-    public $link;
-    public $host;
-    public $base;
-    public $user;
-    public $password;
-    public $EXTENTION_OK;
-
-    public function __construct($params = array()){
-      $this->host = isset($params["host"]) ? $params["host"] : "content/data/sqlite";
-      $this->base = isset($params["base"]) ? $params["base"] : "mtweb.db";
-      $this->user = isset($params["user"]) ? $params["user"] : "";
-      $this->password = isset($params["password"]) ? $params["password"] : "";
-      $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_sqlite"));
+  class mw_pdo_sqlite extends mw_sgbd{
+
+    public function name(){
+      return "PDO SQLite";
     }
 
-    public function get_link(){
-      return $this->link;
+    public function default_params(){
+      return array(
+        "host" => "content/data/sqlite",
+        "base" => "mtweb.db",
+        "user" => "",
+        "password" => ""
+      );
     }
 
-    public function extention_ok(&$env){
-      return $this->EXTENTION_OK;
+    public function validate_extention(){
+      return extension_loaded("pdo") && extension_loaded("pdo_sqlite");
     }
 
     public function authentication_required(){
       return false;
     }
 
-    public function sgbd_name(){
-      return "PDO SQLite";
-    }
-
     public function connect($host, $base, $user, $password){
       if($host) $host .= substr($host, -1) != "/" ? "/" : "";
       try{
@@ -53,6 +43,7 @@
     }
 
     public function desc_table($table_name){
+      $table_name = $this->replace_prefixes($table_name);
       if(strpos($table_name, "'") !== false){
         throw new Exception($this->exception_out("nom de table avec un simple quote"));
       }
@@ -78,6 +69,7 @@
     }
 
     public function table_exists($table_name){
+      $table_name = $this->replace_prefixes($table_name);
       if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
       $EXISTS = false;
       try{
@@ -97,6 +89,7 @@
     }
 
     public function field_exists($table_name, $field_name){
+      $table_name = $this->replace_prefixes($table_name);
       if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
       if(!($desc = $this->desc_table($table_name))){
         throw new Exception($this->exception_out("Impossible de lire la description de la table"));
       return $EXISTS;
     }
 
-    public function query($query_string){\r
+    public function query($query_string){
+      $query_string = $this->replace_prefixes($query_string);\r
       if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
       if(!($result = $this->link->query($query_string))){
         throw new Exception($this->exception_out("Syntaxe invalide dans une requete"));