@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | protected function checkPropertyExists($name) { |
| 112 | 112 | if (!array_key_exists($name, static::$_properties)) { |
| 113 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] not exists when accessing via __get/__set', ERR_ERROR); |
|
| 113 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] not exists when accessing via __get/__set', ERR_ERROR); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | protected function checkOverwriteAdjusted($name) { |
| 118 | 118 | if (array_key_exists($name, $this->propertiesAdjusted)) { |
| 119 | - throw new PropertyAccessException('Property [' . get_called_class() . '::' . $name . '] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
| 119 | + throw new PropertyAccessException('Property ['.get_called_class().'::'.$name.'] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $result = null; |
| 136 | 136 | // Now deciding - will we call a protected setter or will we work with protected property |
| 137 | - if (method_exists($this, $methodName = 'get' . ucfirst($name))) { |
|
| 137 | + if (method_exists($this, $methodName = 'get'.ucfirst($name))) { |
|
| 138 | 138 | // If method exists - just calling it |
| 139 | 139 | $result = call_user_func_array(array($this, $methodName), array()); |
| 140 | - } elseif (property_exists($this, $propertyName = '_' . $name)) { |
|
| 140 | + } elseif (property_exists($this, $propertyName = '_'.$name)) { |
|
| 141 | 141 | // No getter exists - works directly with protected property |
| 142 | 142 | $result = $this->$propertyName; |
| 143 | 143 | } else { |
| 144 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] does not have getter/property to get', ERR_ERROR); |
|
| 144 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] does not have getter/property to get', ERR_ERROR); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | return $result; |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | protected function ___set($name, $value) { |
| 160 | 160 | $result = null; |
| 161 | 161 | // Now deciding - will we call a protected setter or will we work with protected property |
| 162 | - if (method_exists($this, $methodName = 'set' . ucfirst($name))) { |
|
| 162 | + if (method_exists($this, $methodName = 'set'.ucfirst($name))) { |
|
| 163 | 163 | // If method exists - just calling it |
| 164 | 164 | // TODO - should return TRUE if value changed or FALSE otherwise |
| 165 | 165 | $result = call_user_func_array(array($this, $methodName), array($value)); |
| 166 | - } elseif (property_exists($this, $propertyName = '_' . $name)) { |
|
| 166 | + } elseif (property_exists($this, $propertyName = '_'.$name)) { |
|
| 167 | 167 | // No setter exists - works directly with protected property |
| 168 | 168 | $this->$propertyName = $value; |
| 169 | 169 | } else { |
| 170 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] does not have setter/property to set', ERR_ERROR); |
|
| 170 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] does not have setter/property to set', ERR_ERROR); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // TODO - should be primed only if value changed |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $this->checkPropertyExists($name); |
| 211 | 211 | |
| 212 | 212 | // Now deciding - will we call a protected setter or will we work with protected property |
| 213 | - if (method_exists($this, $methodName = 'adj' . ucfirst($name))) { |
|
| 213 | + if (method_exists($this, $methodName = 'adj'.ucfirst($name))) { |
|
| 214 | 214 | // If method exists - just calling it |
| 215 | 215 | // TODO - should return TRUE if value changed or FALSE otherwise |
| 216 | 216 | $newValue = call_user_func_array(array($this, $methodName), array($diff)); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param db_mysql|null $db |
| 87 | 87 | */ |
| 88 | 88 | public static function setDb($db = null) { |
| 89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
| 89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
| 90 | 90 | $db = null; |
| 91 | 91 | } |
| 92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
| 150 | 150 | $dbId = idval($dbId); |
| 151 | 151 | if ($dbId <= 0) { |
| 152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
| 152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
| 153 | 153 | |
| 154 | 154 | return; |
| 155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $this->dbGetLockById($this->_dbId); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;", true); |
|
| 164 | + $db_row = doquery("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;", true); |
|
| 165 | 165 | if (empty($db_row)) { |
| 166 | 166 | return; |
| 167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if ($this->isNew()) { |
| 194 | 194 | // No DB_ID - new unit |
| 195 | 195 | if ($this->isEmpty()) { |
| 196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
| 196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
| 197 | 197 | } |
| 198 | 198 | $this->dbInsert(); |
| 199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $this->dbDelete(); |
| 203 | 203 | } else { |
| 204 | 204 | if (!sn_db_transaction_check(false)) { |
| 205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
| 205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
| 206 | 206 | } |
| 207 | 207 | $this->dbUpdate(); |
| 208 | 208 | } |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | // TODO - protected |
| 231 | 231 | public function dbInsert() { |
| 232 | 232 | if (!$this->isNew()) { |
| 233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
| 233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
| 234 | 234 | } |
| 235 | 235 | $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet()); |
| 236 | 236 | |
| 237 | 237 | if (empty($this->_dbId)) { |
| 238 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
| 238 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | return $this->_dbId; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | public function dbUpdate() { |
| 249 | 249 | // TODO - Update |
| 250 | 250 | if ($this->isNew()) { |
| 251 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
| 251 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
| 252 | 252 | } |
| 253 | 253 | $this->db_field_update($this->dbMakeFieldSet(true)); |
| 254 | 254 | } |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | // TODO - protected |
| 260 | 260 | public function dbDelete() { |
| 261 | 261 | if ($this->isNew()) { |
| 262 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
| 262 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
| 263 | 263 | } |
| 264 | - doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
|
| 264 | + doquery("DELETE FROM {{".static::$_table."}} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId); |
|
| 265 | 265 | $this->_dbId = 0; |
| 266 | 266 | // Обо всём остальном должен позаботиться контейнер |
| 267 | 267 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $fields = implode(',', array_keys($field_set)); |
| 415 | 415 | |
| 416 | 416 | $result = 0; |
| 417 | - if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) { |
|
| 417 | + if (classSupernova::db_query("INSERT INTO `{{".static::$_table."}}` ({$fields}) VALUES ({$values});")) { |
|
| 418 | 418 | $result = db_insert_id(); |
| 419 | 419 | } |
| 420 | 420 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | return empty($set_string) |
| 452 | 452 | ? true |
| 453 | - : classSupernova::db_query("UPDATE `{{" . static::$_table . "}}` SET {$set_string} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
|
| 453 | + : classSupernova::db_query("UPDATE `{{".static::$_table."}}` SET {$set_string} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | } |