Browse Source

Remplacement utilisation CLASS_NAME par get_class($this)

Simounet 4 years ago
parent
commit
e9736ac693
6 changed files with 13 additions and 17 deletions
  1. 0 1
      Configuration.class.php
  2. 0 1
      Event.class.php
  3. 0 1
      Feed.class.php
  4. 0 1
      Folder.class.php
  5. 13 12
      MysqlEntity.class.php
  6. 0 1
      User.class.php

+ 0 - 1
Configuration.class.php

@@ -11,7 +11,6 @@ class Configuration extends MysqlEntity{
 
     protected $id,$key,$value,$confTab;
     protected $TABLE_NAME = 'configuration';
-    protected $CLASS_NAME = 'Configuration';
     protected $object_fields =
     array(
         'id'=>'key',

+ 0 - 1
Event.class.php

@@ -10,7 +10,6 @@ class Event extends MysqlEntity{
 
     protected $id,$title,$guid,$content,$description,$pudate,$link,$feed,$category,$creator,$unread,$favorite;
     protected $TABLE_NAME = 'event';
-    protected $CLASS_NAME = 'Event';
     protected $object_fields =
     array(
         'id'=>'key',

+ 0 - 1
Feed.class.php

@@ -10,7 +10,6 @@ class Feed extends MysqlEntity{
 
     protected $id,$name,$url,$events=array(),$description,$website,$folder,$lastupdate,$isverbose,$lastSyncInError;
     protected $TABLE_NAME = 'feed';
-    protected $CLASS_NAME = 'Feed';
     protected $object_fields =
     array(
         'id'=>'key',

+ 0 - 1
Folder.class.php

@@ -10,7 +10,6 @@ class Folder extends MysqlEntity{
 
     protected $id,$name,$parent,$isopen;
     protected $TABLE_NAME = 'folder';
-    protected $CLASS_NAME = 'Folder';
     protected $object_fields =
     array(
         'id'=>'key',

+ 13 - 12
MysqlEntity.class.php

@@ -97,7 +97,7 @@ class MysqlEntity
     public function destroy($debug=false)
     {
         $query = 'DROP TABLE IF EXISTS `'.MYSQL_PREFIX.$this->TABLE_NAME.'`;';
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $myQuery = $this->customQuery($query);
     }
 
@@ -111,7 +111,7 @@ class MysqlEntity
     public function truncate($debug=false)
     {
         $query = 'TRUNCATE TABLE `'.MYSQL_PREFIX.$this->TABLE_NAME.'`;';
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $myQuery = $this->customQuery($query);
     }
 
@@ -139,7 +139,7 @@ class MysqlEntity
         ENGINE InnoDB,
         DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
         ;';
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $myQuery = $this->customQuery($query);
     }
 
@@ -172,7 +172,7 @@ class MysqlEntity
             }
 
             $query .=';';
-            if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+            if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
 
         $this->customQuery($query);
     }
@@ -213,7 +213,7 @@ class MysqlEntity
 
             $query .=');';
         }
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $this->customQuery($query);
         $this->$id_field =  (!isset($this->$id_field)?$this->dbconnector->connection->insert_id:$this->$id_field);
     }
@@ -237,7 +237,7 @@ class MysqlEntity
         }
         $query .= $this->getWhereClause($columns2, $operation);
 
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $this->customQuery($query);
     }
 
@@ -276,11 +276,12 @@ class MysqlEntity
             if($limit!=null) $query .='LIMIT '.$limit.' ';
             $query .=';';
 
-            if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+            if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
             $result = $this->customQuery($query);
             while($queryReturn = $result->fetch_assoc()){
 
-                $object = new $this->CLASS_NAME();
+                $thisClass = get_class($this);
+                $object = new $thisClass();
                 foreach($this->object_fields as $field=>$type){
                     if(isset($queryReturn[$field])) $object->$field = $queryReturn[$field];
                 }
@@ -346,7 +347,7 @@ class MysqlEntity
             }
         }
         $query = 'SELECT COUNT(1) FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'`'.$whereClause;
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $myQuery = $this->customQuery($query);
         $number = $myQuery->fetch_array();
         return $number[0];
@@ -371,14 +372,14 @@ class MysqlEntity
             $whereClause .= '`'.$column.'`'.$operation.'"'.$this->secure($value, $column).'"';
         }
         $query = 'DELETE FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'` WHERE '.$whereClause.' ;';
-        if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
+        if($this->debug)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.$this->dbconnector->connection->error;
         $this->customQuery($query);
 
     }
 
     ///@TODO: pourquoi deux méthodes différentes qui font la même chose ?
     public function customExecute($request){
-        if($this->debugAllQuery)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$request.'<br>'.$this->dbconnector->connection->error;
+        if($this->debugAllQuery)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$request.'<br>'.$this->dbconnector->connection->error;
         $result = $this->dbconnector->connection->query($request);
         $error = $this->error();
         if ($error) {
@@ -392,7 +393,7 @@ class MysqlEntity
     }
 
     public function customQuery($request){
-        if($this->debugAllQuery)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$request.'<br>'.$this->dbconnector->connection->error;
+        if($this->debugAllQuery)echo '<hr>'.get_class($this).' ('.__METHOD__ .') : Requete --> '.$request.'<br>'.$this->dbconnector->connection->error;
         $result = $this->dbconnector->connection->query($request);
         $error = $this->error();
         if ($error) {

+ 0 - 1
User.class.php

@@ -15,7 +15,6 @@ class User extends MysqlEntity{
 
     protected $id,$login,$password,$otpSecret;
     protected $TABLE_NAME = 'user';
-    protected $CLASS_NAME = 'User';
     protected $object_fields =
     array(
         'id'=>'key',