@@ -66,6 +66,9 @@ discard block |
||
| 66 | 66 | return $this->adapter->delete($table,$where); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + /** |
|
| 70 | + * @param string $str |
|
| 71 | + */ |
|
| 69 | 72 | protected function escape_str($str, $like = FALSE) |
| 70 | 73 | { |
| 71 | 74 | |
@@ -120,7 +123,6 @@ discard block |
||
| 120 | 123 | |
| 121 | 124 | /** |
| 122 | 125 | * |
| 123 | - * @param type $param |
|
| 124 | 126 | */ |
| 125 | 127 | public function getResultQuery($table,\SimpleORM\ISpecificationCriteria $Criteria ) { |
| 126 | 128 | |
@@ -155,7 +157,7 @@ discard block |
||
| 155 | 157 | /** |
| 156 | 158 | * Создает селект не только для основной таблицы но и для приджойненых таблиц |
| 157 | 159 | * @param type $joins |
| 158 | - * @return type |
|
| 160 | + * @return string |
|
| 159 | 161 | */ |
| 160 | 162 | protected function createSelect($joins) |
| 161 | 163 | { |
@@ -171,8 +173,8 @@ discard block |
||
| 171 | 173 | /** |
| 172 | 174 | * Получение записей по условию |
| 173 | 175 | * @param type $where |
| 174 | - * @param type $limit |
|
| 175 | - * @param type $offset |
|
| 176 | + * @param integer $limit |
|
| 177 | + * @param integer $offset |
|
| 176 | 178 | * @param type $joins |
| 177 | 179 | * @param type $order |
| 178 | 180 | * @param type $manualJoins |
@@ -71,8 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | if(!$like){ |
| 73 | 73 | return $this->adapter->escape_str($str); |
| 74 | - } |
|
| 75 | - else{ |
|
| 74 | + } else{ |
|
| 76 | 75 | return $this->adapter->escape_like_str($str); |
| 77 | 76 | } |
| 78 | 77 | |
@@ -145,8 +144,7 @@ discard block |
||
| 145 | 144 | if(preg_match('~(.*?)\.(.*?)$~is',$table,$m)){ |
| 146 | 145 | $this->database = $m[1]; |
| 147 | 146 | $this->TableName = $m[2]; |
| 148 | - } |
|
| 149 | - else{ |
|
| 147 | + } else{ |
|
| 150 | 148 | $this->TableName = $table; |
| 151 | 149 | } |
| 152 | 150 | } |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * получение защищенного свойства |
| 8 | - * @param type $o |
|
| 9 | - * @param type $name |
|
| 8 | + * @param string $name |
|
| 9 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 10 | 10 | * @return type |
| 11 | 11 | */ |
| 12 | 12 | static public function getProtectedAttribute($obj, $name) |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Добавление значения в защищенное свойтсво |
| 22 | 22 | * @param type $name |
| 23 | - * @param type $valued |
|
| 23 | + * @param type $value |
|
| 24 | 24 | */ |
| 25 | 25 | private function setValueprotectedProperty($name, $value) |
| 26 | 26 | { |
@@ -30,6 +30,10 @@ discard block |
||
| 30 | 30 | $r->setValue($this->object, $value); //изменяем значение |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param SimpleORM\AbstractDataMapper $obj |
|
| 35 | + * @param string $name |
|
| 36 | + */ |
|
| 33 | 37 | static public function callMethod($obj, $name, array $args) { |
| 34 | 38 | $class = new \ReflectionClass($obj); |
| 35 | 39 | $method = $class->getMethod($name); |
@@ -222,19 +222,18 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | if($this->use_joins===true){ |
| 224 | 224 | $value = $mapper->createEntity($row); |
| 225 | - } |
|
| 226 | - else{ |
|
| 225 | + } else{ |
|
| 227 | 226 | $fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key; |
| 228 | 227 | $value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field])); |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | - } |
|
| 232 | - elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 230 | + } elseif(is_string($field) && isset($row[strtolower($field)])){ |
|
| 233 | 231 | $value = $row[strtolower($field)]; |
| 234 | 232 | } |
| 235 | 233 | |
| 236 | - if($value!==false) |
|
| 237 | - $Entity->{$method_set}($value); |
|
| 234 | + if($value!==false) { |
|
| 235 | + $Entity->{$method_set}($value); |
|
| 236 | + } |
|
| 238 | 237 | |
| 239 | 238 | } |
| 240 | 239 | |
@@ -265,18 +264,17 @@ discard block |
||
| 265 | 264 | //-------------------------------------------------------------------- |
| 266 | 265 | if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){ |
| 267 | 266 | $value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() ); |
| 268 | - } |
|
| 269 | - elseif(isset($cfg['relation'])){ |
|
| 267 | + } elseif(isset($cfg['relation'])){ |
|
| 270 | 268 | |
| 271 | - if(isset($cfg['on'])) |
|
| 272 | - $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 273 | - else |
|
| 274 | - $fkey = 'id'; |
|
| 269 | + if(isset($cfg['on'])) { |
|
| 270 | + $fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']); |
|
| 271 | + } else { |
|
| 272 | + $fkey = 'id'; |
|
| 273 | + } |
|
| 275 | 274 | |
| 276 | 275 | $value = $Entity->{$method_get}()->{'get'.$fkey}(); |
| 277 | 276 | |
| 278 | - } |
|
| 279 | - else{ |
|
| 277 | + } else{ |
|
| 280 | 278 | $value = $Entity->{$method_get}(); |
| 281 | 279 | } |
| 282 | 280 | |
@@ -294,8 +292,7 @@ discard block |
||
| 294 | 292 | |
| 295 | 293 | if(is_string($field)){ |
| 296 | 294 | $field = ['field' => $field]; |
| 297 | - } |
|
| 298 | - elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 295 | + } elseif( (is_array($field) && !isset($field['field'])) || empty($field)){ |
|
| 299 | 296 | $field['field'] = $alias; |
| 300 | 297 | } |
| 301 | 298 | |
@@ -377,8 +374,7 @@ discard block |
||
| 377 | 374 | $delete_key > '' && |
| 378 | 375 | $Entity->getId() > 0){ |
| 379 | 376 | $result = $this->db->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'"); |
| 380 | - } |
|
| 381 | - elseif($Entity->getId() > 0){ |
|
| 377 | + } elseif($Entity->getId() > 0){ |
|
| 382 | 378 | |
| 383 | 379 | if($result = $this->db->delete($this->getEntityTable(), $this->getPrimaryKey()." = ".$Entity->getId())){ |
| 384 | 380 | if(method_exists($this, 'onDeleteSuccess' )){ $result = $this->onDeleteSuccess( $Entity );} |
@@ -425,8 +421,9 @@ discard block |
||
| 425 | 421 | $this->use_delete === false && |
| 426 | 422 | $this->setSoftDeleteKey()>'' |
| 427 | 423 | && !isset($specification->getWhere()[$this->setSoftDeleteKey()]) |
| 428 | - ) |
|
| 429 | - $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 424 | + ) { |
|
| 425 | + $specification->setWhere($this->setSoftDeleteKey(),0); |
|
| 426 | + } |
|
| 430 | 427 | } |
| 431 | 428 | |
| 432 | 429 | /** |