getTable.static.diff

webmyster, 08/06/2012 06:52 PM

Download (5.78 KB)

View differences:

inc/commonglpi.class.php (working copy)
62 62
    *
63 63
    * @return string
64 64
   **/
65
   function getType() {
65
   static function getType() {
66 66

  
67
      if ($this->type == -1) {
68
         $this->type = get_class($this);
69
      }
70
      return $this->type;
67
      return get_called_class();
68

  
71 69
   }
72 70

  
73 71

  
inc/computer_device.class.php (working copy)
36 36
   die("Sorry. You can't access directly to this file");
37 37
}
38 38

  
39
/// TODO : create each Computer_Device class (Computer_DeviceProcessor, Computer_DeviceMemory ...) !
39 40

  
41

  
40 42
/**
41 43
 * Relation between Computer and devices
42 44
**/
inc/rule.class.php (working copy)
93 93
   const OR_MATCHING             = "OR";
94 94

  
95 95

  
96
   /**
97
    * Constructor
98
   **/
99
   function __construct() {
100
      // Temproray hack for this class
101
      $this->forceTable('glpi_rules');
96
   // Temproray hack for this class
97
   static function getTable() {
98
      return 'glpi_rules';
102 99
   }
103 100

  
104 101

  
inc/rulemailcollector.class.php (working copy)
44 44
   public $can_sort = true;
45 45

  
46 46

  
47
   /**
48
    * Constructor
49
   **/
50
   function __construct() {
51

  
52
      // Temproray hack for this class
53
      $this->forceTable('glpi_rules');
47
   // Temproray hack for this class
48
   static function getTable() {
49
      return 'glpi_rules';
54 50
   }
55 51

  
56 52

  
inc/ipnetmask.class.php (working copy)
40 40
/// since version 0.84
41 41
class IPNetmask extends IPAddress {
42 42

  
43
   var $notable = true;
43
   static protected $notable = true;
44 44

  
45 45

  
46 46
   /**
inc/ruleright.class.php (working copy)
44 44
   public $specific_parameters = true;
45 45

  
46 46

  
47
   /**
48
    * Constructor
49
   **/
50
   function __construct() {
51
      // Temproray hack for this class
52
      $this->forceTable('glpi_rules');
47
   // Temproray hack for this class
48
   static function getTable() {
49
      return 'glpi_rules';
53 50
   }
54 51

  
55 52

  
inc/rulecollection.class.php (working copy)
58 58
   var $entity                                = 0;
59 59

  
60 60

  
61
   /**
62
    * Constructor
63
   **/
64
   function __construct() {
65
      $this->forceTable('glpi_rules');
61
   // Temproray hack for this class
62
   static function getTable() {
63
      return 'glpi_rules';
66 64
   }
67 65

  
68 66

  
inc/commondbtm.class.php (working copy)
49 49
   var $no_form_page = false;
50 50

  
51 51
   /// Set true to desactivate auto compute table name
52
   var $notable = false;
52
   static protected $notable = false;
53 53

  
54 54
   ///Additional fiedls for dictionnary processing
55 55
   var $additional_fields_for_dictionnary = array();
56 56

  
57 57
   /// Forward entity datas to linked items
58 58
   protected $forward_entity_to = array();
59
   /// Table name cache : set dynamically calling getTable
60
   protected $table = "";
61 59
   /// Foreign key field cache : set dynamically calling getForeignKeyField
62 60
   protected $fkfield = "";
63 61

  
......
83 81
    *
84 82
    * @return string
85 83
   **/
86
   function getTable() {
84
   static function getTable() {
87 85

  
88
      if (empty($this->table)
89
          && !$this->notable) {
90
         $this->table = getTableForItemType($this->getType());
86
      $name = 'glpi_table_of_'.get_called_class();
87

  
88
      if (empty($_SESSION[$name])
89
          && (!static::$notable)) {
90
         $_SESSION[$name] = getTableForItemType(get_called_class());
91 91
      }
92 92

  
93
      return $this->table;
93
      return $_SESSION[$name];
94 94
   }
95 95

  
96 96

  
......
101 101
    *
102 102
    * @return nothing
103 103
   **/
104
   function forceTable($table) {
105
      $this->table = $table;
104
   static function forceTable($table) {
105

  
106
      $name = 'glpi_table_of_'.get_called_class();
107
      $_SESSION[$name] = $table;
108

  
106 109
   }
107 110

  
108 111

  
inc/dbconnection.class.php (working copy)
37 37
**/
38 38
class DBConnection extends CommonDBTM {
39 39

  
40
   var $notable = true;
40
   static protected $notable = true;
41 41

  
42 42

  
43 43
   static function getTypeName($nb=0) {
inc/report.class.php (working copy)
43 43
**/
44 44
class Report {
45 45

  
46
   var $notable = false;
46
   static protected $notable = false;
47 47

  
48 48

  
49 49
   static function getTypeName($nb=0) {
inc/dbmysql.class.php (working copy)
286 286
    * @return number of rows
287 287
   **/
288 288
   function numrows($result) {
289
      if (!$result instanceof mysqli_result) {
290
         throw new Exception('Invalid SQL result !');
291
      }
289 292
      return $result->num_rows;
290 293
   }
291 294