public attr / function, constructeurs __construct
[mtweb] / mw / app / data / impl / mw_pdo_sqlite.php
index 1e4f68e..8fd7deb 100644 (file)
@@ -2,34 +2,38 @@
 
   class mw_pdo_sqlite{
 
-    var $link;
-
-    var $host;
-    var $base;
-    var $user;
-    var $password;
-
-    var $EXTENTION_OK;
+    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"));
+    }
 
-    function get_link(){
+    public function get_link(){
       return $this->link;
     }
 
-    function extention_ok(&$env) { return $this->EXTENTION_OK; }
-
-    function authentication_required() { return false; }
+    public function extention_ok(&$env){
+      return $this->EXTENTION_OK;
+    }
 
-    function sgbd_name() { return "PDO SQLite"; }
+    public function authentication_required(){
+      return false;
+    }
 
-    function mw_pdo_sqlite($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"));
+    public function sgbd_name(){
+      return "PDO SQLite";
     }
 
-    function connect($host, $base, $user, $password){
+    public function connect($host, $base, $user, $password){
       if($host) $host .= substr($host, -1) != "/" ? "/" : "";
       try{
         $this->link = null;
       return true;
     }
 
-    function select_db($db_name){\r
+    public function select_db($db_name){\r
       $this->base = $db_name;\r
       return $this->connect($this->host, $this->base, $this->user, $this->password);\r
     }
 
-    function desc_table($table_name){
+    public function desc_table($table_name){
       if(strpos($table_name, "'") !== false){
         throw new Exception($this->exception_out("nom de table avec un simple quote"));
       }
@@ -73,7 +77,7 @@
       return $desc;
     }
 
-    function table_exists($table_name){
+    public function table_exists($table_name){
       if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
       $EXISTS = false;
       try{
@@ -92,7 +96,7 @@
       return $EXISTS;\r
     }
 
-    function field_exists($table_name, $field_name){
+    public function field_exists($table_name, $field_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;
     }
 
-    function query($query_string){\r
+    public function query($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"));
       return $result;\r
     }
 
-    function fetch_assoc($rst){
+    public function fetch_assoc($rst){
       if(!$this->link){
         throw new Exception($this->exception_out("fetch_assoc sans connexion"));
       }
       return $tuple;
     }
 
-    function insert_id(){
+    public function insert_id(){
       if(!$this->link){
         throw new Exception($this->exception_out("insert_id sans connexion"));
       }
       return $id;
     }
 
-    function free_result($rst){
+    public function free_result($rst){
       if(!$this->link){
         throw new Exception($this->exception_out("free_result sans connexion"));
       }
       return true;
     }
 
-    function close(){
+    public function close(){
       $this->link = null;
       return true;
     }
 
-    function exception_out($message){\r
+    public function exception_out($message){\r
       return "[erreur] sqlite : ".$message;\r
     }
 
   }
-
-?>
\ No newline at end of file