Passed
Pull Request — master (#54)
by
unknown
03:01
created
library/Trapdirector/TrapsProcess/MibDatabase.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
         }
61 61
         $oidIndex=$this->dbOidIndex[$this->oidDesc['oid']]['key']; // Get index in dbOidAll
62 62
         $dbOid=$this->dbOidAll[$oidIndex]; // Get array of element
63
-        if ( $this->oidDesc['name'] != $dbOid['name'] ||
63
+        if ($this->oidDesc['name'] != $dbOid['name'] ||
64 64
             $this->oidDesc['mib'] != $dbOid['mib'] ||
65
-            $this->oidDesc['type'] !=$dbOid['type']
65
+            $this->oidDesc['type'] != $dbOid['type']
66 66
             )
67 67
         { // Do update
68 68
             $sql='UPDATE '.$this->getTrapsDB()->dbPrefix.'mib_cache SET '.
@@ -75,23 +75,23 @@  discard block
 block discarded – undo
75 75
                 ':name' => $this->oidDesc['name'],
76 76
                 ':type' => $this->oidDesc['type'],
77 77
                 ':mib' => $this->oidDesc['mib'],
78
-                ':tc' =>  $this->oidDesc['textconv']??'null',
79
-                ':display_hint' => $this->oidDesc['dispHint']??'null' ,
80
-                ':syntax' => $this->oidDesc['syntax']==null??'null',
81
-                ':type_enum' => $this->oidDesc['type_enum']??'null',
82
-                ':description' => $this->oidDesc['description']??'null',
78
+                ':tc' =>  $this->oidDesc['textconv'] ?? 'null',
79
+                ':display_hint' => $this->oidDesc['dispHint'] ?? 'null',
80
+                ':syntax' => $this->oidDesc['syntax'] == null ?? 'null',
81
+                ':type_enum' => $this->oidDesc['type_enum'] ?? 'null',
82
+                ':description' => $this->oidDesc['description'] ?? 'null',
83 83
                 ':id' => $this->dbOidIndex[$this->oidDesc['oid']]['id']
84 84
             );
85 85
             
86 86
             if ($sqlQuery->execute($sqlParam) === false) {
87
-                $this->getLogging()->log('Error in query : ' . $sql,ERROR,'');
87
+                $this->getLogging()->log('Error in query : '.$sql, ERROR, '');
88 88
             }
89
-            $this->getLogging()->log('Trap updated : '.$this->oidDesc['name'] . ' / OID : '.$this->oidDesc['oid'],DEBUG );
89
+            $this->getLogging()->log('Trap updated : '.$this->oidDesc['name'].' / OID : '.$this->oidDesc['oid'], DEBUG);
90 90
             return 1;
91 91
         }
92 92
         else
93 93
         {
94
-            $this->getLogging()->log('Trap unchanged : '.$this->oidDesc['name'] . ' / OID : '.$this->oidDesc['oid'],DEBUG );
94
+            $this->getLogging()->log('Trap unchanged : '.$this->oidDesc['name'].' / OID : '.$this->oidDesc['oid'], DEBUG);
95 95
             return 0;
96 96
         }
97 97
     }
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         $db_conn=$this->getTrapsDB()->db_connect_trap();
108 108
         $sql='INSERT INTO '.$this->getTrapsDB()->dbPrefix.'mib_cache '.
109 109
             '(oid, name, type , mib, textual_convention, display_hint '.
110
-            ', syntax, type_enum , description ) ' .
110
+            ', syntax, type_enum , description ) '.
111 111
             'values (:oid, :name , :type ,:mib ,:tc , :display_hint'.
112 112
             ', :syntax, :type_enum, :description )';
113 113
         
114
-        if ($this->getTrapsDB()->trapDBType == 'pgsql') $sql .= 'RETURNING id';
114
+        if ($this->getTrapsDB()->trapDBType == 'pgsql') $sql.='RETURNING id';
115 115
         
116 116
         $sqlQuery=$db_conn->prepare($sql);
117 117
         
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
             ':name' => $this->oidDesc['name'],
121 121
             ':type' => $this->oidDesc['type'],
122 122
             ':mib' => $this->oidDesc['mib'],
123
-            ':tc' =>  $this->oidDesc['textconv']??'null',
124
-            ':display_hint' => $this->oidDesc['dispHint']??'null',
125
-            ':syntax' => $this->oidDesc['syntax']??'null',
126
-            ':type_enum' => $this->oidDesc['type_enum']??'null',
127
-            ':description' => $this->oidDesc['description']??'null'
123
+            ':tc' =>  $this->oidDesc['textconv'] ?? 'null',
124
+            ':display_hint' => $this->oidDesc['dispHint'] ?? 'null',
125
+            ':syntax' => $this->oidDesc['syntax'] ?? 'null',
126
+            ':type_enum' => $this->oidDesc['type_enum'] ?? 'null',
127
+            ':description' => $this->oidDesc['description'] ?? 'null'
128 128
         );
129 129
         
130 130
         if ($sqlQuery->execute($sqlParam) === false) {
131
-            $this->getLogging()->log('Error in query : ' . $sql,1,'');
131
+            $this->getLogging()->log('Error in query : '.$sql, 1, '');
132 132
         }
133 133
         
134 134
         switch ($this->getTrapsDB()->trapDBType)
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
             case 'pgsql':
137 137
                 // Get last id to insert oid/values in secondary table
138 138
                 if (($inserted_id_ret=$sqlQuery->fetch(PDO::FETCH_ASSOC)) === false) {
139
-                    $this->getLogging()->log('Error getting id - pgsql - ',1,'');
139
+                    $this->getLogging()->log('Error getting id - pgsql - ', 1, '');
140 140
                 }
141
-                if (! isset($inserted_id_ret['id'])) {
142
-                    $this->getLogging()->log('Error getting id - pgsql - empty.',ERROR);
141
+                if (!isset($inserted_id_ret['id'])) {
142
+                    $this->getLogging()->log('Error getting id - pgsql - empty.', ERROR);
143 143
                     return 0;
144 144
                 }
145 145
                 $this->dbOidIndex[$this->oidDesc['oid']]['id']=$inserted_id_ret['id'];
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
                 // Get last id to insert oid/values in secondary table
149 149
                 $sql='SELECT LAST_INSERT_ID();';
150 150
                 if (($ret_code=$db_conn->query($sql)) === false) {
151
-                    $this->getLogging()->log('Erreur getting id - mysql - ',ERROR);
151
+                    $this->getLogging()->log('Erreur getting id - mysql - ', ERROR);
152 152
                     return 0;
153 153
                 }
154 154
                 
155 155
                 $inserted_id=$ret_code->fetch(PDO::FETCH_ASSOC)['LAST_INSERT_ID()'];
156
-                if ($inserted_id==false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue");
156
+                if ($inserted_id == false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue");
157 157
                 $this->dbOidIndex[$this->oidDesc['oid']]['id']=$inserted_id;
158 158
                 break;
159 159
             default:
160
-                $this->getLogging()->log('Error SQL type Unknown : '.$this->getTrapsDB()->trapDBType,ERROR);
160
+                $this->getLogging()->log('Error SQL type Unknown : '.$this->getTrapsDB()->trapDBType, ERROR);
161 161
                 return 0;
162 162
         }
163 163
         
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
         $db_conn=$this->getTrapsDB()->db_connect_trap();
178 178
         // Get all objects
179 179
         $sql='SELECT * FROM '.$this->getTrapsDB()->dbPrefix.'mib_cache_trap_object where trap_id='.$trapId.';';
180
-        $this->getLogging()->log('SQL query get all traps: '.$sql,DEBUG );
180
+        $this->getLogging()->log('SQL query get all traps: '.$sql, DEBUG);
181 181
         if (($ret_code=$db_conn->query($sql)) === false) {
182
-            $this->getLogging()->log('No result in query : ' . $sql,1,'');
182
+            $this->getLogging()->log('No result in query : '.$sql, 1, '');
183 183
         }
184 184
         $dbObjectsRaw=$ret_code->fetchAll();
185 185
         
Please login to merge, or discard this patch.