@@ -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 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @var array |
62 | 62 | */ |
63 | - private static $usedInstanceIds = []; |
|
63 | + private static $usedInstanceIds = [ ]; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @var array |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | while ( in_array( $instance, self::$usedInstanceIds ) ) { |
133 | 133 | $instance = QueryHelper::random( 7 ); |
134 | 134 | } |
135 | - self::$usedInstanceIds[] = $instance; |
|
135 | + self::$usedInstanceIds[ ] = $instance; |
|
136 | 136 | |
137 | 137 | return $instance; |
138 | 138 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return true; |
180 | 180 | |
181 | 181 | if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
182 | - $this->syntaxEL[ $name ][] = $value; |
|
182 | + $this->syntaxEL[ $name ][ ] = $value; |
|
183 | 183 | else |
184 | 184 | $this->syntaxEL[ $name ] = $value; |
185 | 185 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $search |
242 | 242 | * @return string |
243 | 243 | */ |
244 | - public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
|
244 | + public function bindParamsExpression( $expression, array $params = [ ], $search = '?' ) |
|
245 | 245 | { |
246 | 246 | if ( !count( $params ) ) |
247 | 247 | return $expression; |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
253 | 253 | |
254 | 254 | $i = 0; |
255 | - $arrayReturn = []; |
|
255 | + $arrayReturn = [ ]; |
|
256 | 256 | $expressionToArray = explode( $search, $expression ); |
257 | 257 | |
258 | 258 | foreach ( $expressionToArray as $sub ) { |
259 | - $arrayReturn[] = $sub; |
|
260 | - $arrayReturn[] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
259 | + $arrayReturn[ ] = $sub; |
|
260 | + $arrayReturn[ ] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : ''; |
|
261 | 261 | $i++; |
262 | 262 | } |
263 | 263 |
@@ -97,8 +97,9 @@ discard block |
||
97 | 97 | { |
98 | 98 | $this->syntaxEL = $this->init(); |
99 | 99 | |
100 | - foreach ( $this->syntaxEL as $name => $value ) |
|
101 | - $this->typeEL[ $name ] = gettype( $value ); |
|
100 | + foreach ( $this->syntaxEL as $name => $value ) { |
|
101 | + $this->typeEL[ $name ] = gettype( $value ); |
|
102 | + } |
|
102 | 103 | |
103 | 104 | } |
104 | 105 | |
@@ -184,16 +185,19 @@ discard block |
||
184 | 185 | */ |
185 | 186 | public function setElement( $name, $value ) |
186 | 187 | { |
187 | - if ( !array_key_exists( $name, $this->syntaxEL ) ) |
|
188 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
188 | + if ( !array_key_exists( $name, $this->syntaxEL ) ) { |
|
189 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
190 | + } |
|
189 | 191 | |
190 | - if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) |
|
191 | - return true; |
|
192 | + if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) { |
|
193 | + return true; |
|
194 | + } |
|
192 | 195 | |
193 | - if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) |
|
194 | - $this->syntaxEL[ $name ][] = $value; |
|
195 | - else |
|
196 | - $this->syntaxEL[ $name ] = $value; |
|
196 | + if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) { |
|
197 | + $this->syntaxEL[ $name ][] = $value; |
|
198 | + } else { |
|
199 | + $this->syntaxEL[ $name ] = $value; |
|
200 | + } |
|
197 | 201 | |
198 | 202 | return true; |
199 | 203 | } |
@@ -206,8 +210,9 @@ discard block |
||
206 | 210 | */ |
207 | 211 | public function replaceElement( $elementName, $elementValue ) |
208 | 212 | { |
209 | - if ( !array_key_exists( $elementName, $this->syntaxEL ) ) |
|
210 | - throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
213 | + if ( !array_key_exists( $elementName, $this->syntaxEL ) ) { |
|
214 | + throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND ); |
|
215 | + } |
|
211 | 216 | |
212 | 217 | $this->syntaxEL[ $elementName ] = $elementValue; |
213 | 218 | } |
@@ -240,11 +245,13 @@ discard block |
||
240 | 245 | */ |
241 | 246 | public function bindParamsExpression( $expression, array $params = [], $search = '?' ) |
242 | 247 | { |
243 | - if ( !count( $params ) ) |
|
244 | - return $expression; |
|
248 | + if ( !count( $params ) ) { |
|
249 | + return $expression; |
|
250 | + } |
|
245 | 251 | |
246 | - if ( strpos( $expression, $search ) === false ) |
|
247 | - return $expression; |
|
252 | + if ( strpos( $expression, $search ) === false ) { |
|
253 | + return $expression; |
|
254 | + } |
|
248 | 255 | |
249 | 256 | $params = array_slice( $params, 0, substr_count( $expression, $search ) ); |
250 | 257 | |
@@ -277,8 +284,9 @@ discard block |
||
277 | 284 | public function prepare( $fieldName = '' ) |
278 | 285 | { |
279 | 286 | $fieldName = trim( $fieldName ); |
280 | - if ( in_array( $fieldName, $this->reserved ) ) |
|
281 | - $fieldName = '`' . $fieldName . '`'; |
|
287 | + if ( in_array( $fieldName, $this->reserved ) ) { |
|
288 | + $fieldName = '`' . $fieldName . '`'; |
|
289 | + } |
|
282 | 290 | |
283 | 291 | return $fieldName; |
284 | 292 | } |
@@ -60,10 +60,11 @@ discard block |
||
60 | 60 | private function __construct() |
61 | 61 | { |
62 | 62 | $vendorCfg = __DIR__ . '/../../../../../vendor-cfg/qpdb_db_config.php'; |
63 | - if ( file_exists( $vendorCfg ) ) |
|
64 | - $this->dbConfig = require $vendorCfg; |
|
65 | - else |
|
66 | - $this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php'; |
|
63 | + if ( file_exists( $vendorCfg ) ) { |
|
64 | + $this->dbConfig = require $vendorCfg; |
|
65 | + } else { |
|
66 | + $this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php'; |
|
67 | + } |
|
67 | 68 | |
68 | 69 | $this->buildConfig(); |
69 | 70 | } |
@@ -146,8 +147,9 @@ discard block |
||
146 | 147 | |
147 | 148 | public function useTablePrefix() |
148 | 149 | { |
149 | - if ( !empty( $this->dbConfig[ 'use_table_prefix' ] ) ) |
|
150 | - return $this->dbConfig[ 'use_table_prefix' ]; |
|
150 | + if ( !empty( $this->dbConfig[ 'use_table_prefix' ] ) ) { |
|
151 | + return $this->dbConfig[ 'use_table_prefix' ]; |
|
152 | + } |
|
151 | 153 | |
152 | 154 | return false; |
153 | 155 | } |
@@ -182,8 +184,9 @@ discard block |
||
182 | 184 | private function readMasterDataConnect() |
183 | 185 | { |
184 | 186 | |
185 | - if ( !isset( $this->dbConfig[ 'master_data_connect' ][ 0 ] ) ) |
|
186 | - throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING ); |
|
187 | + if ( !isset( $this->dbConfig[ 'master_data_connect' ][ 0 ] ) ) { |
|
188 | + throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING ); |
|
189 | + } |
|
187 | 190 | |
188 | 191 | $dataConnection = $this->dbConfig[ 'master_data_connect' ]; |
189 | 192 |
@@ -97,7 +97,7 @@ |
||
97 | 97 | * @param array $dbConfig |
98 | 98 | * @return $this |
99 | 99 | */ |
100 | - public function withConfigArray ( array $dbConfig ) |
|
100 | + public function withConfigArray( array $dbConfig ) |
|
101 | 101 | { |
102 | 102 | $this->dbConfig = $dbConfig; |
103 | 103 | $this->buildConfig(); |