@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | $this->queryStructure->setElement( QueryStructure::TABLE, $tableName ); |
56 | 56 | |
57 | 57 | $tableSelectParams = $table->getBindParams(); |
58 | - foreach ( $tableSelectParams as $key => $value ) |
|
59 | - $this->queryStructure->setParams( $key, $value ); |
|
58 | + foreach ( $tableSelectParams as $key => $value ) { |
|
59 | + $this->queryStructure->setParams( $key, $value ); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | } |
62 | 63 | } |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //??? |
108 | 109 | } |
109 | 110 | |
110 | - if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) |
|
111 | - $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
111 | + if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) { |
|
112 | + $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
|
113 | + } |
|
112 | 114 | |
113 | 115 | $syntax = array(); |
114 | 116 | |
@@ -190,8 +192,9 @@ discard block |
||
190 | 192 | return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
191 | 193 | break; |
192 | 194 | case $this->queryStructure->getElement( QueryStructure::FIRST ): |
193 | - if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) ) |
|
194 | - return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
195 | + if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) ) { |
|
196 | + return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
|
197 | + } |
|
195 | 198 | |
196 | 199 | return DbService::getInstance()->row( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
197 | 200 | break; |
@@ -115,62 +115,62 @@ |
||
115 | 115 | /** |
116 | 116 | * Explain |
117 | 117 | */ |
118 | - $syntax[] = $this->getExplainSyntax(); |
|
118 | + $syntax[ ] = $this->getExplainSyntax(); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * SELECT statement |
122 | 122 | */ |
123 | - $syntax[] = $this->statement; |
|
123 | + $syntax[ ] = $this->statement; |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * PRIORITY |
127 | 127 | */ |
128 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
128 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * DISTINCT clause |
132 | 132 | */ |
133 | - $syntax[] = $this->getDistinctSyntax(); |
|
133 | + $syntax[ ] = $this->getDistinctSyntax(); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * FIELDS |
137 | 137 | */ |
138 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
138 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::FIELDS ); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * FROM table or queryStructure |
142 | 142 | */ |
143 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
143 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * JOIN CLAUSES |
147 | 147 | */ |
148 | - $syntax[] = $this->getJoinSyntax(); |
|
148 | + $syntax[ ] = $this->getJoinSyntax(); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * WHERE clause |
152 | 152 | */ |
153 | - $syntax[] = $this->getWhereSyntax(); |
|
153 | + $syntax[ ] = $this->getWhereSyntax(); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * GROUP BY clause |
157 | 157 | */ |
158 | - $syntax[] = $this->getGroupBySyntax(); |
|
158 | + $syntax[ ] = $this->getGroupBySyntax(); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * HAVING clause |
162 | 162 | */ |
163 | - $syntax[] = $this->getHavingSyntax(); |
|
163 | + $syntax[ ] = $this->getHavingSyntax(); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * ORDER BY clause |
167 | 167 | */ |
168 | - $syntax[] = $this->getOrderBySyntax(); |
|
168 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * LIMIT clause |
172 | 172 | */ |
173 | - $syntax[] = $this->getLimitSyntax(); |
|
173 | + $syntax[ ] = $this->getLimitSyntax(); |
|
174 | 174 | |
175 | 175 | $syntax = implode( ' ', $syntax ); |
176 | 176 |
@@ -45,22 +45,26 @@ |
||
45 | 45 | { |
46 | 46 | $table = trim( $table ); |
47 | 47 | |
48 | - if ( '' === $table ) |
|
49 | - throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
48 | + if ( '' === $table ) { |
|
49 | + throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
50 | + } |
|
50 | 51 | |
51 | - if ( DbConfig::getInstance()->useTablePrefix() ) |
|
52 | - $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
52 | + if ( DbConfig::getInstance()->useTablePrefix() ) { |
|
53 | + $table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table ); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | return $table; |
55 | 57 | } |
56 | 58 | |
57 | 59 | private function validateTableSubQuery( $table ) |
58 | 60 | { |
59 | - if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) |
|
60 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
61 | + if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) { |
|
62 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
63 | + } |
|
61 | 64 | |
62 | - if ( !is_a( $table, QuerySelect::class ) ) |
|
63 | - throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
65 | + if ( !is_a( $table, QuerySelect::class ) ) { |
|
66 | + throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT ); |
|
67 | + } |
|
64 | 68 | |
65 | 69 | return $table; |
66 | 70 | } |
@@ -85,12 +85,10 @@ |
||
85 | 85 | $fh = fopen( $log, 'a+' ); |
86 | 86 | fwrite( $fh, $messageFormat ); |
87 | 87 | fclose( $fh ); |
88 | - } |
|
89 | - else { |
|
88 | + } else { |
|
90 | 89 | $this->edit( $log, $messageFormat ); |
91 | 90 | } |
92 | - } |
|
93 | - else { |
|
91 | + } else { |
|
94 | 92 | if ( mkdir( $this->path, 0777 ) === true ) { |
95 | 93 | $this->write( $message ); |
96 | 94 | } |
@@ -60,32 +60,32 @@ |
||
60 | 60 | /** |
61 | 61 | * Explain |
62 | 62 | */ |
63 | - $syntax[] = $this->getExplainSyntax(); |
|
63 | + $syntax[ ] = $this->getExplainSyntax(); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * UPDATE statement |
67 | 67 | */ |
68 | - $syntax[] = $this->statement; |
|
68 | + $syntax[ ] = $this->statement; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * PRIORITY |
72 | 72 | */ |
73 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
73 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * IGNORE clause |
77 | 77 | */ |
78 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
78 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * INTO table |
82 | 82 | */ |
83 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
83 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * FIELDS update |
87 | 87 | */ |
88 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
88 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
89 | 89 | |
90 | 90 | $syntax = implode( ' ', $syntax ); |
91 | 91 |
@@ -52,47 +52,47 @@ |
||
52 | 52 | /** |
53 | 53 | * Explain |
54 | 54 | */ |
55 | - $syntax[] = $this->getExplainSyntax(); |
|
55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * UPDATE statement |
59 | 59 | */ |
60 | - $syntax[] = $this->statement; |
|
60 | + $syntax[ ] = $this->statement; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * PRIORITY |
64 | 64 | */ |
65 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * IGNORE clause |
69 | 69 | */ |
70 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
70 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * TABLE update |
74 | 74 | */ |
75 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
75 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * FIELDS update |
79 | 79 | */ |
80 | - $syntax[] = $this->getSettingFieldsSyntax(); |
|
80 | + $syntax[ ] = $this->getSettingFieldsSyntax(); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * WHERE clause |
84 | 84 | */ |
85 | - $syntax[] = $this->getWhereSyntax(); |
|
85 | + $syntax[ ] = $this->getWhereSyntax(); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * ORDER BY clause |
89 | 89 | */ |
90 | - $syntax[] = $this->getOrderBySyntax(); |
|
90 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * LIMIT clause |
94 | 94 | */ |
95 | - $syntax[] = $this->getLimitSyntax(); |
|
95 | + $syntax[ ] = $this->getLimitSyntax(); |
|
96 | 96 | |
97 | 97 | $syntax = implode( ' ', $syntax ); |
98 | 98 |
@@ -106,8 +106,9 @@ |
||
106 | 106 | */ |
107 | 107 | public function execute() |
108 | 108 | { |
109 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
110 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
109 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
110 | + throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
111 | + } |
|
111 | 112 | |
112 | 113 | return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
113 | 114 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var array |
37 | 37 | */ |
38 | - protected $usedInstanceIds = []; |
|
38 | + protected $usedInstanceIds = [ ]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param array $params |
62 | 62 | * @return $this |
63 | 63 | */ |
64 | - public function withBindParams( array $params = [] ) |
|
64 | + public function withBindParams( array $params = [ ] ) |
|
65 | 65 | { |
66 | 66 | $this->queryStructure->replaceElement( QueryStructure::BIND_PARAMS, $params ); |
67 | 67 |
@@ -52,37 +52,37 @@ |
||
52 | 52 | /** |
53 | 53 | * Explain |
54 | 54 | */ |
55 | - $syntax[] = $this->getExplainSyntax(); |
|
55 | + $syntax[ ] = $this->getExplainSyntax(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * UPDATE statement |
59 | 59 | */ |
60 | - $syntax[] = $this->statement; |
|
60 | + $syntax[ ] = $this->statement; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * PRIORITY |
64 | 64 | */ |
65 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
65 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * TABLE update |
69 | 69 | */ |
70 | - $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
70 | + $syntax[ ] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * WHERE clause |
74 | 74 | */ |
75 | - $syntax[] = $this->getWhereSyntax(); |
|
75 | + $syntax[ ] = $this->getWhereSyntax(); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * ORDER BY clause |
79 | 79 | */ |
80 | - $syntax[] = $this->getOrderBySyntax(); |
|
80 | + $syntax[ ] = $this->getOrderBySyntax(); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * LIMIT clause |
84 | 84 | */ |
85 | - $syntax[] = $this->getLimitSyntax(); |
|
85 | + $syntax[ ] = $this->getLimitSyntax(); |
|
86 | 86 | |
87 | 87 | $syntax = implode( ' ', $syntax ); |
88 | 88 |
@@ -96,8 +96,9 @@ |
||
96 | 96 | public function execute() |
97 | 97 | { |
98 | 98 | |
99 | - if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) |
|
100 | - throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
99 | + if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) { |
|
100 | + throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
101 | + } |
|
101 | 102 | |
102 | 103 | return DbService::getInstance()->query( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) ); |
103 | 104 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $usedInstanceIds = []; |
|
52 | + protected $usedInstanceIds = [ ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string |
@@ -49,32 +49,32 @@ |
||
49 | 49 | /** |
50 | 50 | * Explain |
51 | 51 | */ |
52 | - $syntax[] = $this->getExplainSyntax(); |
|
52 | + $syntax[ ] = $this->getExplainSyntax(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * UPDATE statement |
56 | 56 | */ |
57 | - $syntax[] = $this->statement; |
|
57 | + $syntax[ ] = $this->statement; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * PRIORITY |
61 | 61 | */ |
62 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
62 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * IGNORE clause |
66 | 66 | */ |
67 | - $syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
67 | + $syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : ''; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * INTO table |
71 | 71 | */ |
72 | - $syntax[] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
72 | + $syntax[ ] = 'INTO ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * FIELDS update |
76 | 76 | */ |
77 | - $syntax[] = $this->getInsertMultipleRowsSyntax(); |
|
77 | + $syntax[ ] = $this->getInsertMultipleRowsSyntax(); |
|
78 | 78 | |
79 | 79 | $syntax = implode( ' ', $syntax ); |
80 | 80 |