Completed
Push — work-fleets ( 355465...808c81 )
by SuperNova.WS
06:24
created
includes/classes/DBRow.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
    * @param db_mysql|null $db
98 98
    */
99 99
   public static function setDb($db = null) {
100
-    if(empty($db) || !($db instanceof db_mysql)) {
100
+    if (empty($db) || !($db instanceof db_mysql)) {
101 101
       $db = null;
102 102
     }
103 103
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    */
165 165
   public function __get($name) {
166 166
     // Redirecting inaccessible get to __call which will handle the rest
167
-    return $this->__call('get' . ucfirst($name), array());
167
+    return $this->__call('get'.ucfirst($name), array());
168 168
   }
169 169
 
170 170
   /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
   // TODO - сеттер должен параллельно изменять значение db_row - for now...
177 177
   public function __set($name, $value) {
178 178
     // Redirecting inaccessible set to __call which will handle the rest
179
-    $this->__call('set' . ucfirst($name), array($value));
179
+    $this->__call('set'.ucfirst($name), array($value));
180 180
   }
181 181
 
182 182
   /**
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
     // If method is not getter or setter OR property name not exists in $_properties - raising exception
196 196
     // Descendants can catch this Exception to make own __call magic
197 197
     if (($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
198
-      throw new ExceptionPropertyNotExists('Property ' . $propertyName . ' not exists when calling getter/setter ' . get_called_class() . '::' . $name, ERR_ERROR);
198
+      throw new ExceptionPropertyNotExists('Property '.$propertyName.' not exists when calling getter/setter '.get_called_class().'::'.$name, ERR_ERROR);
199 199
     }
200 200
 
201 201
     // TODO check for read-only
202 202
 
203 203
     if ($left3 == 'set') {
204 204
       if (!empty($this->propertiesAdjusted[$propertyName])) {
205
-        throw new PropertyAccessException('Property ' . $propertyName . ' already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::' . $name, ERR_ERROR);
205
+        throw new PropertyAccessException('Property '.$propertyName.' already was adjusted so no SET is possible until dbSave in '.get_called_class().'::'.$name, ERR_ERROR);
206 206
       }
207 207
       $this->propertiesChanged[$propertyName] = 1;
208 208
     }
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 
218 218
     // Is it getter?
219 219
     if ($left3 === 'get') {
220
-      return $this->{'_' . $propertyName};
220
+      return $this->{'_'.$propertyName};
221 221
     }
222 222
 
223 223
     // Not getter? Then it's setter
224
-    $this->{'_' . $propertyName} = $arguments[0];
224
+    $this->{'_'.$propertyName} = $arguments[0];
225 225
 
226 226
     return null;
227 227
   }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
   public function dbLoad($dbId, $lockSkip = false) {
240 240
     $dbId = idval($dbId);
241 241
     if ($dbId <= 0) {
242
-      classSupernova::$debug->error(get_called_class() . '::dbLoad $dbId not positive = ' . $dbId);
242
+      classSupernova::$debug->error(get_called_class().'::dbLoad $dbId not positive = '.$dbId);
243 243
 
244 244
       return;
245 245
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
       $this->dbGetLockById($this->_dbId);
252 252
     }
253 253
 
254
-    $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;", true);
254
+    $db_row = doquery("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;", true);
255 255
     if (empty($db_row)) {
256 256
       return;
257 257
     }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     if ($this->isNew()) {
284 284
       // No DB_ID - new unit
285 285
       if ($this->isEmpty()) {
286
-        classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
286
+        classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave');
287 287
       }
288 288
       $this->dbInsert();
289 289
     } else {
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         $this->dbDelete();
293 293
       } else {
294 294
         if (!sn_db_transaction_check(false)) {
295
-          classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
295
+          classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate');
296 296
         }
297 297
         $this->dbUpdate();
298 298
       }
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
   // TODO - protected
321 321
   public function dbInsert() {
322 322
     if (!$this->isNew()) {
323
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
323
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert');
324 324
     }
325 325
     $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet());
326 326
 
327 327
     if (empty($this->_dbId)) {
328
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
328
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert');
329 329
     }
330 330
 
331 331
     return $this->_dbId;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
   public function dbUpdate() {
339 339
     // TODO - Update
340 340
     if ($this->isNew()) {
341
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
341
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate');
342 342
     }
343 343
     $this->db_field_update($this->dbMakeFieldSet(true));
344 344
   }
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
   // TODO - protected
350 350
   public function dbDelete() {
351 351
     if ($this->isNew()) {
352
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
352
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete');
353 353
     }
354
-    doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
354
+    doquery("DELETE FROM {{".static::$_table."}} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId);
355 355
     $this->_dbId = 0;
356 356
     // Обо всём остальном должен позаботиться контейнер
357 357
   }
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     $fields = implode(',', array_keys($field_set));
505 505
 
506 506
     $result = 0;
507
-    if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
507
+    if (classSupernova::db_query("INSERT INTO `{{".static::$_table."}}` ({$fields}) VALUES ({$values});")) {
508 508
       $result = db_insert_id();
509 509
     }
510 510
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 
541 541
     return empty($set_string)
542 542
       ? true
543
-      : classSupernova::db_query("UPDATE `{{" . static::$_table . "}}` SET {$set_string} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
543
+      : classSupernova::db_query("UPDATE `{{".static::$_table."}}` SET {$set_string} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId);
544 544
   }
545 545
 
546 546
 }
Please login to merge, or discard this patch.