@@ -5,10 +5,10 @@ |
||
5 | 5 | use HnrAzevedo\Datamanager\Datamanager; |
6 | 6 | |
7 | 7 | /** |
8 | - * @property string $name |
|
9 | - * @property string $email |
|
10 | - * @property string $password |
|
11 | - */ |
|
8 | + * @property string $name |
|
9 | + * @property string $email |
|
10 | + * @property string $password |
|
11 | + */ |
|
12 | 12 | class User extends Datamanager{ |
13 | 13 | |
14 | 14 | public function __construct() |
@@ -9,11 +9,11 @@ |
||
9 | 9 | * @property string $email |
10 | 10 | * @property string $password |
11 | 11 | */ |
12 | -class User extends Datamanager{ |
|
12 | +class User extends Datamanager { |
|
13 | 13 | |
14 | 14 | public function __construct() |
15 | 15 | { |
16 | - parent::create('user','id'); |
|
16 | + parent::create('user', 'id'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -24,7 +24,7 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if(!Connect::getInstance()->inTransaction()){ |
27 | - return Connect::getInstance()->beginTransaction(); |
|
27 | + return Connect::getInstance()->beginTransaction(); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | switch ($transaction) { |
@@ -6,24 +6,24 @@ discard block |
||
6 | 6 | use Exception; |
7 | 7 | use PDO; |
8 | 8 | |
9 | -trait CrudTrait{ |
|
9 | +trait CrudTrait { |
|
10 | 10 | |
11 | 11 | protected ?DatamanagerException $fail = null; |
12 | 12 | |
13 | 13 | protected function check_fail() |
14 | 14 | { |
15 | - if(!is_null($this->fail)){ |
|
15 | + if (!is_null($this->fail)) { |
|
16 | 16 | throw $this->fail; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function transaction(string $transaction): ?bool |
21 | 21 | { |
22 | - if(array_key_exists($transaction,['begin','commit','rollback'])){ |
|
22 | + if (array_key_exists($transaction, ['begin', 'commit', 'rollback'])) { |
|
23 | 23 | throw new DatamanagerException("{$transaction} é um estado inválido para transações."); |
24 | 24 | } |
25 | 25 | |
26 | - if(!Connect::getInstance()->inTransaction()){ |
|
26 | + if (!Connect::getInstance()->inTransaction()) { |
|
27 | 27 | return Connect::getInstance()->beginTransaction(); |
28 | 28 | } |
29 | 29 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | - protected function select(string $query,array $data): ?array |
|
37 | + protected function select(string $query, array $data): ?array |
|
38 | 38 | { |
39 | - try{ |
|
39 | + try { |
|
40 | 40 | $stmt = Connect::getInstance()->prepare("{$query}"); |
41 | 41 | $stmt->execute($data); |
42 | 42 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
43 | - }catch(Exception $exception){ |
|
43 | + } catch (Exception $exception) { |
|
44 | 44 | $this->fail = new DatamanagerException($exception->getMessage(), $exception->getCode(), $exception); |
45 | 45 | } |
46 | 46 | return []; |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | protected function describe(): array |
50 | 50 | { |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $stmt = Connect::getInstance()->prepare("DESCRIBE {$this->table}"); |
53 | 53 | $stmt->execute(); |
54 | 54 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
55 | - }catch(Exception $exception){ |
|
55 | + } catch (Exception $exception) { |
|
56 | 56 | $this->fail = new DatamanagerException($exception->getMessage(), $exception->getCode(), $exception); |
57 | 57 | return []; |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | try { |
64 | 64 | $columns = implode(", ", array_keys($data)); |
65 | - $values = ":" . implode(", :", array_keys($data)); |
|
65 | + $values = ":".implode(", :", array_keys($data)); |
|
66 | 66 | |
67 | 67 | $stmt = Connect::getInstance()->prepare("INSERT INTO {$this->table} ({$columns}) VALUES ({$values})"); |
68 | 68 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | try { |
104 | 104 | $stmt = Connect::getInstance()->prepare("DELETE FROM {$this->table} WHERE {$terms}"); |
105 | 105 | |
106 | - if($params){ |
|
106 | + if ($params) { |
|
107 | 107 | parse_str($params, $arr); |
108 | 108 | $stmt->execute($arr); |
109 | 109 | return true; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $stmt = Connect::getInstance()->prepare("{$query}"); |
41 | 41 | $stmt->execute($data); |
42 | 42 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
43 | - }catch(Exception $exception){ |
|
43 | + } catch(Exception $exception){ |
|
44 | 44 | $this->fail = new DatamanagerException($exception->getMessage(), $exception->getCode(), $exception); |
45 | 45 | } |
46 | 46 | return []; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $stmt = Connect::getInstance()->prepare("DESCRIBE {$this->table}"); |
53 | 53 | $stmt->execute(); |
54 | 54 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
55 | - }catch(Exception $exception){ |
|
55 | + } catch(Exception $exception){ |
|
56 | 56 | $this->fail = new DatamanagerException($exception->getMessage(), $exception->getCode(), $exception); |
57 | 57 | return []; |
58 | 58 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Datamanager; |
4 | 4 | |
5 | -trait DataTrait{ |
|
5 | +trait DataTrait { |
|
6 | 6 | use CrudTrait, CheckTrait; |
7 | 7 | |
8 | 8 | protected ?string $table = null; |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | protected function mountRemove(): array |
25 | 25 | { |
26 | 26 | $return = ['data' => '', 'where' => '']; |
27 | - foreach($this->where as $clause => $condition){ |
|
28 | - if(strlen($clause) === 0){ |
|
27 | + foreach ($this->where as $clause => $condition) { |
|
28 | + if (strlen($clause) === 0) { |
|
29 | 29 | $return['where'] .= " {$clause} {$condition[0]} {$condition[1]} :q_{$condition[0]} "; |
30 | 30 | $return['data'] .= "q_{$condition[0]}={$condition[2]}&"; |
31 | 31 | continue; |
32 | 32 | } |
33 | 33 | |
34 | - foreach($condition as $value){ |
|
34 | + foreach ($condition as $value) { |
|
35 | 35 | $return['where'] .= " {$clause} {$value[0]} {$value[1]} :q_{$value[0]} "; |
36 | 36 | $return['data'] .= "q_{$value[0]}={$value[2]}&"; |
37 | 37 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $return = ['data' => []]; |
45 | 45 | |
46 | 46 | foreach ($this->data as $key => $value) { |
47 | - if($this->upgradeable($key) && !$this->isIncremented($key)){ |
|
47 | + if ($this->upgradeable($key) && !$this->isIncremented($key)) { |
|
48 | 48 | $return['data'][$key] = $this->data[$key]['value']; |
49 | 49 | } |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $key = (!$key) ? '' : " {$key} "; |
62 | 62 | |
63 | - if(is_array($value[0])){ |
|
63 | + if (is_array($value[0])) { |
|
64 | 64 | |
65 | 65 | foreach ($value as $k => $v) { |
66 | 66 | $return['where'] .= " {$key} {$v[0]} {$v[1]} :q_{$v[0]} "; |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | |
80 | 80 | protected function mountSelect() |
81 | 81 | { |
82 | - $select = implode(',',array_keys($this->select)); |
|
82 | + $select = implode(',', array_keys($this->select)); |
|
83 | 83 | |
84 | - $this->query = str_replace('*', $select,$this->query); |
|
84 | + $this->query = str_replace('*', $select, $this->query); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | protected function mountLimit() |
88 | 88 | { |
89 | - if(!is_null($this->limit)){ |
|
89 | + if (!is_null($this->limit)) { |
|
90 | 90 | $this->query .= " LIMIT {$this->limit}"; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | protected function mountOffset() |
95 | 95 | { |
96 | - if(!is_null($this->offset)){ |
|
96 | + if (!is_null($this->offset)) { |
|
97 | 97 | $this->query .= " OFFSET {$this->offset}"; |
98 | 98 | } |
99 | 99 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Datamanager; |
4 | 4 | |
5 | -trait SynchronizeTrait{ |
|
5 | +trait SynchronizeTrait { |
|
6 | 6 | use CrudTrait; |
7 | 7 | |
8 | 8 | protected ?string $table = null; |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $type = $value; |
44 | 44 | |
45 | - if(strpos($value,'(')){ |
|
46 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['varchar','char','text'])) ? 'string' : $type; |
|
47 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['tinyint','mediumint','smallint','bigtint','int'])) ? 'int' : $type; |
|
48 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['decimal','float','double','real'])) ? 'float' : $type; |
|
45 | + if (strpos($value, '(')) { |
|
46 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['varchar', 'char', 'text'])) ? 'string' : $type; |
|
47 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['tinyint', 'mediumint', 'smallint', 'bigtint', 'int'])) ? 'int' : $type; |
|
48 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['decimal', 'float', 'double', 'real'])) ? 'float' : $type; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $this->mountTable_Maxlength($field, $type, $value); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function mountTable_Maxlength(string $field, string $type, $default = null) |
56 | 56 | { |
57 | - $maxlength = (in_array( $type , ['string','float','int'])) ? substr($default,(strpos($default,'(')+1),-1) : 0; |
|
58 | - $maxlength = (in_array( $type , ['date'])) ? 10 : $maxlength; |
|
59 | - $maxlength = (in_array( $type , ['datetime'])) ? 19 : $maxlength; |
|
60 | - $maxlength = (in_array( $type , ['boolean'])) ? 1 : $maxlength; |
|
57 | + $maxlength = (in_array($type, ['string', 'float', 'int'])) ? substr($default, (strpos($default, '(') + 1), -1) : 0; |
|
58 | + $maxlength = (in_array($type, ['date'])) ? 10 : $maxlength; |
|
59 | + $maxlength = (in_array($type, ['datetime'])) ? 19 : $maxlength; |
|
60 | + $maxlength = (in_array($type, ['boolean'])) ? 1 : $maxlength; |
|
61 | 61 | $this->$field = ['maxlength' => $maxlength]; |
62 | 62 | } |
63 | 63 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class DatamanagerException extends Exception{ |
|
7 | +class DatamanagerException extends Exception { |
|
8 | 8 | |
9 | 9 | public function __construct($message, $code = 0, Exception $previous = null) |
10 | 10 | { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __toString() |
15 | 15 | { |
16 | - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
16 | + return __CLASS__.": [{$this->code}]: {$this->message}\n"; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -11,20 +11,20 @@ discard block |
||
11 | 11 | protected ?string $table = null; |
12 | 12 | protected ?string $primary = null; |
13 | 13 | protected array $data = []; |
14 | - protected array $where = [''=> ["1",'=',"1"] ]; |
|
14 | + protected array $where = [''=> ["1", '=', "1"]]; |
|
15 | 15 | |
16 | - public function __set(string $prop,$value) |
|
16 | + public function __set(string $prop, $value) |
|
17 | 17 | { |
18 | - if(is_array($value)){ |
|
18 | + if (is_array($value)) { |
|
19 | 19 | $attr = array_keys($value)[0]; |
20 | 20 | $this->data[$prop][$attr] = $value[$attr]; |
21 | 21 | return $this; |
22 | 22 | } |
23 | 23 | |
24 | - if($this->full){ |
|
25 | - switch($this->data[$prop]['type']){ |
|
24 | + if ($this->full) { |
|
25 | + switch ($this->data[$prop]['type']) { |
|
26 | 26 | case 'date': |
27 | - $value = (date_format( date_create_from_format(DATAMANAGER_CONFIG['dateformat'],$value) , 'Y-m-d')); |
|
27 | + $value = (date_format(date_create_from_format(DATAMANAGER_CONFIG['dateformat'], $value), 'Y-m-d')); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | { |
47 | 47 | $this->isSettable($field); |
48 | 48 | |
49 | - if($this->full){ |
|
50 | - switch($this->data[$field]['type']){ |
|
51 | - case 'date': $this->data[$field]['value'] = (date_format( date_create_from_format('Y-m-d' , $this->data[$field]['value'] ) , DATAMANAGER_CONFIG['dateformat'])); |
|
49 | + if ($this->full) { |
|
50 | + switch ($this->data[$field]['type']) { |
|
51 | + case 'date': $this->data[$field]['value'] = (date_format(date_create_from_format('Y-m-d', $this->data[$field]['value']), DATAMANAGER_CONFIG['dateformat'])); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $deniable = (is_array($deniable)) ? $deniable : [$deniable]; |
66 | 66 | |
67 | 67 | foreach ($deniable as $field) { |
68 | - if(!array_key_exists($field,$this->data)){ |
|
68 | + if (!array_key_exists($field, $this->data)) { |
|
69 | 69 | throw new DatamanagerException("{$field} field does not exist in the table {$this->table}."); |
70 | 70 | } |
71 | 71 | |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | public function orderBy(string $field, string $ord = 'ASC') |
87 | 87 | { |
88 | - $this->isSettable( str_replace(['asc','ASC','desc','DESC',' '],'',$field) ); |
|
88 | + $this->isSettable(str_replace(['asc', 'ASC', 'desc', 'DESC', ' '], '', $field)); |
|
89 | 89 | |
90 | - $ord = (strpos(strtolower($field),'asc') || strpos(strtolower($field),'desc')) ? '' : $ord; |
|
90 | + $ord = (strpos(strtolower($field), 'asc') || strpos(strtolower($field), 'desc')) ? '' : $ord; |
|
91 | 91 | |
92 | 92 | $this->order = " ORDER BY {$field} {$ord} "; |
93 | 93 | return $this; |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | |
112 | 112 | public function where(array $where) |
113 | 113 | { |
114 | - $this->where['AND'] = (array_key_exists('AND',$this->where)) ?? ''; |
|
114 | + $this->where['AND'] = (array_key_exists('AND', $this->where)) ?? ''; |
|
115 | 115 | $w = []; |
116 | 116 | foreach ($where as $condition => $values) { |
117 | 117 | |
118 | - if(!is_array($values)){ |
|
118 | + if (!is_array($values)) { |
|
119 | 119 | $w['AND'][] = $values; |
120 | 120 | continue; |
121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | - $this->where = array_merge($this->where,$w); |
|
129 | + $this->where = array_merge($this->where, $w); |
|
130 | 130 | |
131 | 131 | return $this; |
132 | 132 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $string = ''; |
181 | 181 | foreach ($this->data as $key => $value) { |
182 | 182 | |
183 | - if(gettype($value)==='object'){ |
|
183 | + if (gettype($value) === 'object') { |
|
184 | 184 | $value = $value->getData()[$this->primary]['value']; |
185 | 185 | } |
186 | 186 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | private function removeById(): bool |
193 | 193 | { |
194 | - $delete = $this->delete("{$this->primary}=:{$this->primary}","{$this->primary}={$this->getData()[$this->primary]['value']}"); |
|
194 | + $delete = $this->delete("{$this->primary}=:{$this->primary}", "{$this->primary}={$this->getData()[$this->primary]['value']}"); |
|
195 | 195 | |
196 | 196 | $this->check_fail(); |
197 | 197 | |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | |
201 | 201 | public function findById($id) |
202 | 202 | { |
203 | - return $this->where([$this->primary,'=',$id]); |
|
203 | + return $this->where([$this->primary, '=', $id]); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | public function execute() |
207 | 207 | { |
208 | - if(!is_null($this->clause) && $this->clause == 'remove'){ |
|
208 | + if (!is_null($this->clause) && $this->clause == 'remove') { |
|
209 | 209 | return $this->remove(true); |
210 | 210 | } |
211 | 211 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $this->mountSelect(); |
215 | 215 | |
216 | - $where = substr($this->mountWhereExec()['where'],0,-1); |
|
216 | + $where = substr($this->mountWhereExec()['where'], 0, -1); |
|
217 | 217 | $this->query .= " WHERE {$where} "; |
218 | 218 | |
219 | 219 | $this->query .= $this->order; |
@@ -4,36 +4,36 @@ discard block |
||
4 | 4 | |
5 | 5 | use HnrAzevedo\Datamanager\DatamanagerException; |
6 | 6 | |
7 | -trait CheckTrait{ |
|
7 | +trait CheckTrait { |
|
8 | 8 | |
9 | 9 | protected function check_where_array(array $where) |
10 | 10 | { |
11 | - if(count($where) != 3){ |
|
12 | - throw new DatamanagerException("Condition where set incorrectly: ".implode(' ',$where)); |
|
11 | + if (count($where) != 3) { |
|
12 | + throw new DatamanagerException("Condition where set incorrectly: ".implode(' ', $where)); |
|
13 | 13 | } |
14 | 14 | |
15 | - if(!array_key_exists($where[0],$this->data) && $this->full){ |
|
15 | + if (!array_key_exists($where[0], $this->data) && $this->full) { |
|
16 | 16 | throw new DatamanagerException("{$where[0]} field does not exist in the table {$this->table}."); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function isSettable(string $prop) |
21 | 21 | { |
22 | - if($this->full && !array_key_exists($prop,$this->data)){ |
|
22 | + if ($this->full && !array_key_exists($prop, $this->data)) { |
|
23 | 23 | throw new DatamanagerException("{$prop} field does not exist in the table {$this->table}."); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | protected function checkLimit() |
28 | 28 | { |
29 | - if(is_null($this->limit)){ |
|
29 | + if (is_null($this->limit)) { |
|
30 | 30 | throw new DatamanagerException("The limit must be set before the offset."); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - protected function checkMaxlength(string $field, $val , $max) |
|
34 | + protected function checkMaxlength(string $field, $val, $max) |
|
35 | 35 | { |
36 | - if(strlen($val) > $max){ |
|
36 | + if (strlen($val) > $max) { |
|
37 | 37 | throw new DatamanagerException("The information provided for column {$field} of table {$this->table} exceeded that allowed."); |
38 | 38 | } |
39 | 39 | } |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | |
46 | 46 | protected function isIncremented(string $field): bool |
47 | 47 | { |
48 | - return ( strstr($this->data[$field]['extra'],'auto_increment') && $field !== $this->primary ); |
|
48 | + return (strstr($this->data[$field]['extra'], 'auto_increment') && $field !== $this->primary); |
|
49 | 49 | } |
50 | 50 | } |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | if (empty(self::$instance)) { |
16 | 16 | try { |
17 | 17 | |
18 | - if(!defined('DATAMANAGER_CONFIG')){ |
|
18 | + if (!defined('DATAMANAGER_CONFIG')) { |
|
19 | 19 | throw new DatamanagerException("Information for connection to the database not defined."); |
20 | 20 | } |
21 | 21 | |
22 | 22 | self::$instance = new PDO( |
23 | - DATAMANAGER_CONFIG['driver'] . ':host='.DATAMANAGER_CONFIG['host'] . ';port='.DATAMANAGER_CONFIG['port'] . ';dbname='.DATAMANAGER_CONFIG['database'] . ';charset='.DATAMANAGER_CONFIG['charset'], |
|
23 | + DATAMANAGER_CONFIG['driver'].':host='.DATAMANAGER_CONFIG['host'].';port='.DATAMANAGER_CONFIG['port'].';dbname='.DATAMANAGER_CONFIG['database'].';charset='.DATAMANAGER_CONFIG['charset'], |
|
24 | 24 | DATAMANAGER_CONFIG['username'], |
25 | 25 | DATAMANAGER_CONFIG['password'], |
26 | 26 | DATAMANAGER_CONFIG['options'] |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return self::$instance; |
33 | 33 | } |
34 | 34 | |
35 | - public static function destroy(){ |
|
35 | + public static function destroy() { |
|
36 | 36 | self::$instance = null; |
37 | 37 | } |
38 | 38 |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | |
5 | 5 | use HnrAzevedo\Datamanager\DatamanagerException; |
6 | 6 | |
7 | -trait EntityTrait{ |
|
7 | +trait EntityTrait { |
|
8 | 8 | public function toEntity() |
9 | 9 | { |
10 | - if($this->getCount() === 0){ |
|
10 | + if ($this->getCount() === 0) { |
|
11 | 11 | return null; |
12 | 12 | } |
13 | 13 | |
14 | 14 | $entity = $this->setByDatabase($this->result[0]); |
15 | 15 | |
16 | - if(count($this->result) > 1){ |
|
16 | + if (count($this->result) > 1) { |
|
17 | 17 | $entity = []; |
18 | 18 | foreach ($this->result as $key => $value) { |
19 | 19 | $entity[] = $this->setByDatabase($value); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $data = []; |
31 | 31 | |
32 | 32 | foreach ($this->data as $key => $value) { |
33 | - if(strstr($this->data[$key]['extra'],'auto_increment')){ |
|
33 | + if (strstr($this->data[$key]['extra'], 'auto_increment')) { |
|
34 | 34 | continue; |
35 | 35 | } |
36 | 36 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->transaction('begin'); |
45 | - try{ |
|
45 | + try { |
|
46 | 46 | |
47 | 47 | $id = $this->insert($data); |
48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $this->transaction('commit'); |
54 | 54 | |
55 | - }catch(DatamanagerException $er){ |
|
55 | + } catch (DatamanagerException $er) { |
|
56 | 56 | $this->transaction('rollback'); |
57 | 57 | throw $er; |
58 | 58 | } |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | |
63 | 63 | public function remove(?bool $exec = false) |
64 | 64 | { |
65 | - if($exec !== null){ |
|
65 | + if ($exec !== null) { |
|
66 | 66 | $this->clause = 'remove'; |
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->clause = null; |
71 | 71 | |
72 | - if(count($this->where) == 1){ |
|
72 | + if (count($this->where) == 1) { |
|
73 | 73 | $this->removeById(); |
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - $this->delete($this->mountRemove()['where'], substr( $this->mountRemove()['data'] ,0,-1) ); |
|
77 | + $this->delete($this->mountRemove()['where'], substr($this->mountRemove()['data'], 0, -1)); |
|
78 | 78 | |
79 | 79 | $this->check_fail(); |
80 | 80 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $this->transaction('begin'); |
87 | 87 | |
88 | - try{ |
|
88 | + try { |
|
89 | 89 | $this->update( |
90 | 90 | $this->mountSave()['data'], |
91 | 91 | "{$this->primary}=:{$this->primary}", |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $this->check_fail(); |
96 | 96 | |
97 | 97 | $this->transaction('commit'); |
98 | - }catch(DatamanagerException $er){ |
|
98 | + } catch (DatamanagerException $er) { |
|
99 | 99 | $this->transaction('rollback'); |
100 | 100 | throw $er; |
101 | 101 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $this->transaction('commit'); |
54 | 54 | |
55 | - }catch(DatamanagerException $er){ |
|
55 | + } catch(DatamanagerException $er){ |
|
56 | 56 | $this->transaction('rollback'); |
57 | 57 | throw $er; |
58 | 58 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $this->check_fail(); |
96 | 96 | |
97 | 97 | $this->transaction('commit'); |
98 | - }catch(DatamanagerException $er){ |
|
98 | + } catch(DatamanagerException $er){ |
|
99 | 99 | $this->transaction('rollback'); |
100 | 100 | throw $er; |
101 | 101 | } |