@@ -52,22 +52,22 @@ discard block |
||
52 | 52 | * @param int $fetchMode |
53 | 53 | * @return array|int|null |
54 | 54 | */ |
55 | - public function query( $query, $params = null, $fetchMode = \PDO::FETCH_ASSOC ) |
|
55 | + public function query($query, $params = null, $fetchMode = \PDO::FETCH_ASSOC) |
|
56 | 56 | { |
57 | 57 | |
58 | - $query = trim( str_replace( "\r", " ", $query ) ); |
|
59 | - $statement = self::getQueryStatement( $query ); |
|
58 | + $query = trim(str_replace("\r", " ", $query)); |
|
59 | + $statement = self::getQueryStatement($query); |
|
60 | 60 | |
61 | - $this->queryInit( $query, $params ); |
|
61 | + $this->queryInit($query, $params); |
|
62 | 62 | |
63 | - if ( $statement === self::QUERY_TYPE_SELECT || |
|
63 | + if ($statement === self::QUERY_TYPE_SELECT || |
|
64 | 64 | $statement === self::QUERY_TYPE_SHOW || |
65 | 65 | $statement === self::QUERY_TYPE_DESC || |
66 | 66 | $statement === self::QUERY_TYPE_EXPLAIN |
67 | 67 | ) { |
68 | - return $this->sQuery->fetchAll( $fetchMode ); |
|
68 | + return $this->sQuery->fetchAll($fetchMode); |
|
69 | 69 | } |
70 | - elseif ( $statement === self::QUERY_TYPE_INSERT || |
|
70 | + elseif ($statement === self::QUERY_TYPE_INSERT || |
|
71 | 71 | $statement === self::QUERY_TYPE_UPDATE || |
72 | 72 | $statement === self::QUERY_TYPE_DELETE |
73 | 73 | ) { |
@@ -84,46 +84,46 @@ discard block |
||
84 | 84 | * @param null $params |
85 | 85 | * @return array|null |
86 | 86 | */ |
87 | - public function column( $query, $params = null ) |
|
87 | + public function column($query, $params = null) |
|
88 | 88 | { |
89 | - $this->queryInit( $query, $params ); |
|
89 | + $this->queryInit($query, $params); |
|
90 | 90 | |
91 | - $query = trim( str_replace( "\r", " ", $query ) ); |
|
92 | - $statement = self::getQueryStatement( $query ); |
|
91 | + $query = trim(str_replace("\r", " ", $query)); |
|
92 | + $statement = self::getQueryStatement($query); |
|
93 | 93 | |
94 | - if ( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
95 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
94 | + if ($statement === self::QUERY_TYPE_EXPLAIN) |
|
95 | + return $this->sQuery->fetchAll(\PDO::FETCH_ASSOC); |
|
96 | 96 | |
97 | - $Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM ); |
|
97 | + $Columns = $this->sQuery->fetchAll(\PDO::FETCH_NUM); |
|
98 | 98 | |
99 | 99 | $column = null; |
100 | 100 | |
101 | - foreach ( $Columns as $cells ) { |
|
101 | + foreach ($Columns as $cells) { |
|
102 | 102 | $column[] = $cells[0]; |
103 | 103 | } |
104 | 104 | |
105 | 105 | return $column; |
106 | 106 | } |
107 | 107 | |
108 | - public function row( $query, $params = null, $fetchmode = \PDO::FETCH_ASSOC ) |
|
108 | + public function row($query, $params = null, $fetchmode = \PDO::FETCH_ASSOC) |
|
109 | 109 | { |
110 | - $this->queryInit( $query, $params ); |
|
110 | + $this->queryInit($query, $params); |
|
111 | 111 | |
112 | - $query = trim( str_replace( "\r", " ", $query ) ); |
|
113 | - $statement = self::getQueryStatement( $query ); |
|
112 | + $query = trim(str_replace("\r", " ", $query)); |
|
113 | + $statement = self::getQueryStatement($query); |
|
114 | 114 | |
115 | - if ( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
116 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
115 | + if ($statement === self::QUERY_TYPE_EXPLAIN) |
|
116 | + return $this->sQuery->fetchAll(\PDO::FETCH_ASSOC); |
|
117 | 117 | |
118 | - $result = $this->sQuery->fetch( $fetchmode ); |
|
118 | + $result = $this->sQuery->fetch($fetchmode); |
|
119 | 119 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued, |
120 | 120 | |
121 | 121 | return $result; |
122 | 122 | } |
123 | 123 | |
124 | - public function single( $query, $params = null ) |
|
124 | + public function single($query, $params = null) |
|
125 | 125 | { |
126 | - $this->queryInit( $query, $params ); |
|
126 | + $this->queryInit($query, $params); |
|
127 | 127 | $result = $this->sQuery->fetchColumn(); |
128 | 128 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued |
129 | 129 | |
@@ -135,57 +135,57 @@ discard block |
||
135 | 135 | * @param string $query |
136 | 136 | * @param array $parameters |
137 | 137 | */ |
138 | - private function queryInit( $query, $parameters = [] ) |
|
138 | + private function queryInit($query, $parameters = []) |
|
139 | 139 | { |
140 | - $this->pdo = DbConnect::getInstance()->getConnection( self::getQueryStatement( $query ) ); |
|
141 | - $startQueryTime = microtime( true ); |
|
140 | + $this->pdo = DbConnect::getInstance()->getConnection(self::getQueryStatement($query)); |
|
141 | + $startQueryTime = microtime(true); |
|
142 | 142 | |
143 | 143 | try { |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Prepare query |
147 | 147 | */ |
148 | - $this->sQuery = $this->pdo->prepare( $query ); |
|
148 | + $this->sQuery = $this->pdo->prepare($query); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * Add parameters to the parameter array |
152 | 152 | */ |
153 | - if ( self::isArrayAssoc( $parameters ) ) |
|
154 | - $this->bindMore( $parameters ); |
|
153 | + if (self::isArrayAssoc($parameters)) |
|
154 | + $this->bindMore($parameters); |
|
155 | 155 | else |
156 | - foreach ( $parameters as $key => $val ) |
|
157 | - $this->parameters[] = array( $key + 1, $val ); |
|
156 | + foreach ($parameters as $key => $val) |
|
157 | + $this->parameters[] = array($key + 1, $val); |
|
158 | 158 | |
159 | - if ( count( $this->parameters ) ) { |
|
160 | - foreach ( $this->parameters as $param => $value ) { |
|
161 | - if ( is_int( $value[1] ) ) { |
|
159 | + if (count($this->parameters)) { |
|
160 | + foreach ($this->parameters as $param => $value) { |
|
161 | + if (is_int($value[1])) { |
|
162 | 162 | $type = \PDO::PARAM_INT; |
163 | 163 | } |
164 | - elseif ( is_bool( $value[1] ) ) { |
|
164 | + elseif (is_bool($value[1])) { |
|
165 | 165 | $type = \PDO::PARAM_BOOL; |
166 | 166 | } |
167 | - elseif ( is_null( $value[1] ) ) { |
|
167 | + elseif (is_null($value[1])) { |
|
168 | 168 | $type = \PDO::PARAM_NULL; |
169 | 169 | } |
170 | 170 | else { |
171 | 171 | $type = \PDO::PARAM_STR; |
172 | 172 | } |
173 | - $this->sQuery->bindValue( $value[0], $value[1], $type ); |
|
173 | + $this->sQuery->bindValue($value[0], $value[1], $type); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | $this->sQuery->execute(); |
178 | 178 | |
179 | - if ( DbConfig::getInstance()->isEnableLogQueryDuration() ) { |
|
180 | - $duration = microtime( true ) - $startQueryTime; |
|
181 | - DbLog::getInstance()->writeQueryDuration( $query, $duration ); |
|
179 | + if (DbConfig::getInstance()->isEnableLogQueryDuration()) { |
|
180 | + $duration = microtime(true) - $startQueryTime; |
|
181 | + DbLog::getInstance()->writeQueryDuration($query, $duration); |
|
182 | 182 | } |
183 | 183 | |
184 | - } catch ( \PDOException $e ) { |
|
185 | - if ( DbConfig::getInstance()->isEnableLogErrors() ) { |
|
186 | - DbLog::getInstance()->writeQueryErros( $query, $e->getCode(), $e->getMessage() ); |
|
184 | + } catch (\PDOException $e) { |
|
185 | + if (DbConfig::getInstance()->isEnableLogErrors()) { |
|
186 | + DbLog::getInstance()->writeQueryErros($query, $e->getCode(), $e->getMessage()); |
|
187 | 187 | } |
188 | - throw new \PDOException( $e->getMessage(), $e->getCode() ); |
|
188 | + throw new \PDOException($e->getMessage(), $e->getCode()); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,19 +195,19 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | |
198 | - public function bindMore( $parray ) |
|
198 | + public function bindMore($parray) |
|
199 | 199 | { |
200 | - if ( !count( $this->parameters ) && is_array( $parray ) ) { |
|
201 | - $columns = array_keys( $parray ); |
|
202 | - foreach ( $columns as $i => &$column ) { |
|
203 | - $this->bind( $column, $parray[ $column ] ); |
|
200 | + if (!count($this->parameters) && is_array($parray)) { |
|
201 | + $columns = array_keys($parray); |
|
202 | + foreach ($columns as $i => &$column) { |
|
203 | + $this->bind($column, $parray[$column]); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - public function bind( $para, $value ) |
|
208 | + public function bind($para, $value) |
|
209 | 209 | { |
210 | - $this->parameters[ sizeof( $this->parameters ) ] = [ ":" . $para, $value ]; |
|
210 | + $this->parameters[sizeof($this->parameters)] = [":" . $para, $value]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | * @param $queryString |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - public static function getQueryStatement( $queryString ) |
|
224 | + public static function getQueryStatement($queryString) |
|
225 | 225 | { |
226 | - $queryString = trim( $queryString ); |
|
226 | + $queryString = trim($queryString); |
|
227 | 227 | |
228 | - if ( $queryString === '' ) { |
|
228 | + if ($queryString === '') { |
|
229 | 229 | return self::QUERY_TYPE_EMPTY; |
230 | 230 | } |
231 | 231 | |
232 | - if ( preg_match( '/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches ) ) { |
|
233 | - switch ( strtolower( $matches[1] ) ) { |
|
232 | + if (preg_match('/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches)) { |
|
233 | + switch (strtolower($matches[1])) { |
|
234 | 234 | case 'select': |
235 | 235 | return self::QUERY_TYPE_SELECT; |
236 | 236 | case 'insert': |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | * @param array $arr |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | - public static function isArrayAssoc( array $arr ) |
|
259 | + public static function isArrayAssoc(array $arr) |
|
260 | 260 | { |
261 | - if ( array() === $arr ) return false; |
|
261 | + if (array() === $arr) return false; |
|
262 | 262 | |
263 | - return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
|
263 | + return array_keys($arr) !== range(0, count($arr) - 1); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public static function getInstance() |
271 | 271 | { |
272 | - if ( null === self::$instance ) { |
|
272 | + if (null === self::$instance) { |
|
273 | 273 | self::$instance = new self(); |
274 | 274 | } |
275 | 275 |
@@ -66,14 +66,12 @@ discard block |
||
66 | 66 | $statement === self::QUERY_TYPE_EXPLAIN |
67 | 67 | ) { |
68 | 68 | return $this->sQuery->fetchAll( $fetchMode ); |
69 | - } |
|
70 | - elseif ( $statement === self::QUERY_TYPE_INSERT || |
|
69 | + } elseif ( $statement === self::QUERY_TYPE_INSERT || |
|
71 | 70 | $statement === self::QUERY_TYPE_UPDATE || |
72 | 71 | $statement === self::QUERY_TYPE_DELETE |
73 | 72 | ) { |
74 | 73 | return $this->sQuery->rowCount(); |
75 | - } |
|
76 | - else { |
|
74 | + } else { |
|
77 | 75 | |
78 | 76 | return NULL; |
79 | 77 | } |
@@ -91,8 +89,9 @@ discard block |
||
91 | 89 | $query = trim( str_replace( "\r", " ", $query ) ); |
92 | 90 | $statement = self::getQueryStatement( $query ); |
93 | 91 | |
94 | - if ( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
95 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
92 | + if ( $statement === self::QUERY_TYPE_EXPLAIN ) { |
|
93 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
94 | + } |
|
96 | 95 | |
97 | 96 | $Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM ); |
98 | 97 | |
@@ -112,8 +111,9 @@ discard block |
||
112 | 111 | $query = trim( str_replace( "\r", " ", $query ) ); |
113 | 112 | $statement = self::getQueryStatement( $query ); |
114 | 113 | |
115 | - if ( $statement === self::QUERY_TYPE_EXPLAIN ) |
|
116 | - return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
114 | + if ( $statement === self::QUERY_TYPE_EXPLAIN ) { |
|
115 | + return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC ); |
|
116 | + } |
|
117 | 117 | |
118 | 118 | $result = $this->sQuery->fetch( $fetchmode ); |
119 | 119 | $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued, |
@@ -150,24 +150,22 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * Add parameters to the parameter array |
152 | 152 | */ |
153 | - if ( self::isArrayAssoc( $parameters ) ) |
|
154 | - $this->bindMore( $parameters ); |
|
155 | - else |
|
156 | - foreach ( $parameters as $key => $val ) |
|
153 | + if ( self::isArrayAssoc( $parameters ) ) { |
|
154 | + $this->bindMore( $parameters ); |
|
155 | + } else { |
|
156 | + foreach ( $parameters as $key => $val ) |
|
157 | 157 | $this->parameters[] = array( $key + 1, $val ); |
158 | + } |
|
158 | 159 | |
159 | 160 | if ( count( $this->parameters ) ) { |
160 | 161 | foreach ( $this->parameters as $param => $value ) { |
161 | 162 | if ( is_int( $value[1] ) ) { |
162 | 163 | $type = \PDO::PARAM_INT; |
163 | - } |
|
164 | - elseif ( is_bool( $value[1] ) ) { |
|
164 | + } elseif ( is_bool( $value[1] ) ) { |
|
165 | 165 | $type = \PDO::PARAM_BOOL; |
166 | - } |
|
167 | - elseif ( is_null( $value[1] ) ) { |
|
166 | + } elseif ( is_null( $value[1] ) ) { |
|
168 | 167 | $type = \PDO::PARAM_NULL; |
169 | - } |
|
170 | - else { |
|
168 | + } else { |
|
171 | 169 | $type = \PDO::PARAM_STR; |
172 | 170 | } |
173 | 171 | $this->sQuery->bindValue( $value[0], $value[1], $type ); |
@@ -246,8 +244,7 @@ discard block |
||
246 | 244 | default: |
247 | 245 | return self::QUERY_TYPE_OTHER; |
248 | 246 | } |
249 | - } |
|
250 | - else { |
|
247 | + } else { |
|
251 | 248 | return self::QUERY_TYPE_OTHER; |
252 | 249 | } |
253 | 250 | } |
@@ -258,7 +255,9 @@ discard block |
||
258 | 255 | */ |
259 | 256 | public static function isArrayAssoc( array $arr ) |
260 | 257 | { |
261 | - if ( array() === $arr ) return false; |
|
258 | + if ( array() === $arr ) { |
|
259 | + return false; |
|
260 | + } |
|
262 | 261 | |
263 | 262 | return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
264 | 263 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() |
29 | 29 | { |
30 | - $this->queryStart = microtime( true ); |
|
30 | + $this->queryStart = microtime(true); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getDuration() |
37 | 37 | { |
38 | - $this->queryEnd = microtime( true ); |
|
38 | + $this->queryEnd = microtime(true); |
|
39 | 39 | |
40 | 40 | return $this->queryEnd - $this->queryStart; |
41 | 41 | } |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @param QueryBuild $queryBuild |
40 | 40 | * @param string $table |
41 | 41 | */ |
42 | - public function __construct( QueryBuild $queryBuild, $table = null ) |
|
42 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
43 | 43 | { |
44 | - parent::__construct( $queryBuild, $table ); |
|
44 | + parent::__construct($queryBuild, $table); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
47 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
48 | 48 | { |
49 | 49 | |
50 | 50 | $syntax = array(); |
@@ -62,17 +62,17 @@ discard block |
||
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 |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | $syntax[] = $this->getLimitSyntax(); |
96 | 96 | |
97 | - $syntax = implode( ' ', $syntax ); |
|
97 | + $syntax = implode(' ', $syntax); |
|
98 | 98 | |
99 | - return $this->getSyntaxReplace( $syntax, $replacement ); |
|
99 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | { |
109 | 109 | |
110 | 110 | if ( |
111 | - $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && |
|
112 | - !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) |
|
111 | + $this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && |
|
112 | + !count($this->queryStructure->getElement(QueryStructure::WHERE)) |
|
113 | 113 | ) |
114 | - throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
114 | + throw new QueryException('Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
115 | 115 | |
116 | 116 | return DbService::getInstance()->query( |
117 | 117 | $this->getSyntax(), |
118 | - $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) |
|
118 | + $this->queryStructure->getElement(QueryStructure::BIND_PARAMS) |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | } |
122 | 122 | \ No newline at end of file |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | * @param QueryBuild $queryBuild |
49 | 49 | * @param string $query |
50 | 50 | */ |
51 | - public function __construct( QueryBuild $queryBuild, $query = '' ) |
|
51 | + public function __construct(QueryBuild $queryBuild, $query = '') |
|
52 | 52 | { |
53 | 53 | $this->queryBuild = $queryBuild; |
54 | 54 | $this->queryStructure = new QueryStructure(); |
55 | - $this->queryStructure->setElement( QueryStructure::STATEMENT, $this->statement ); |
|
56 | - $this->queryStructure->setElement( QueryStructure::QUERY_TYPE, $this->queryBuild->getType() ); |
|
57 | - $this->queryStructure->setElement( QueryStructure::QUERY_STRING, $query ); |
|
55 | + $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
56 | + $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
57 | + $this->queryStructure->setElement(QueryStructure::QUERY_STRING, $query); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
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 | - $this->queryStructure->replaceElement( QueryStructure::BIND_PARAMS, $params ); |
|
66 | + $this->queryStructure->replaceElement(QueryStructure::BIND_PARAMS, $params); |
|
67 | 67 | |
68 | 68 | return $this; |
69 | 69 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param bool|int $replacement |
73 | 73 | * @return mixed |
74 | 74 | */ |
75 | - public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
75 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
76 | 76 | { |
77 | - return $this->queryStructure->getElement( QueryStructure::QUERY_STRING ); |
|
77 | + return $this->queryStructure->getElement(QueryStructure::QUERY_STRING); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getBindParams() |
84 | 84 | { |
85 | - return $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ); |
|
85 | + return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | public function execute() |
92 | 92 | { |
93 | 93 | return DbService::getInstance()->query( |
94 | - $this->queryStructure->getElement( QueryStructure::QUERY_STRING ), |
|
95 | - $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) |
|
94 | + $this->queryStructure->getElement(QueryStructure::QUERY_STRING), |
|
95 | + $this->queryStructure->getElement(QueryStructure::BIND_PARAMS) |
|
96 | 96 | ); |
97 | 97 | } |
98 | 98 |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param QueryBuild $queryBuild |
37 | 37 | * @param string $table |
38 | 38 | */ |
39 | - public function __construct( QueryBuild $queryBuild, $table = null ) |
|
39 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | 40 | { |
41 | - parent::__construct( $queryBuild, $table ); |
|
42 | - $this->queryStructure->setElement( QueryStructure::FIELDS, array() ); |
|
41 | + parent::__construct($queryBuild, $table); |
|
42 | + $this->queryStructure->setElement(QueryStructure::FIELDS, array()); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
45 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
46 | 46 | { |
47 | 47 | $syntax = array(); |
48 | 48 | |
@@ -59,26 +59,26 @@ discard block |
||
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 | 77 | $syntax[] = $this->getInsertMultipleRowsSyntax(); |
78 | 78 | |
79 | - $syntax = implode( ' ', $syntax ); |
|
79 | + $syntax = implode(' ', $syntax); |
|
80 | 80 | |
81 | - return $this->getSyntaxReplace( $syntax, $replacement ); |
|
81 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | return DbService::getInstance()->query( |
88 | 88 | $this->getSyntax(), |
89 | - $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) |
|
89 | + $this->queryStructure->getElement(QueryStructure::BIND_PARAMS) |
|
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @param QueryBuild $queryBuild |
37 | 37 | * @param string $table |
38 | 38 | */ |
39 | - public function __construct( QueryBuild $queryBuild, $table = null ) |
|
39 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
40 | 40 | { |
41 | - parent::__construct( $queryBuild, $table ); |
|
41 | + parent::__construct($queryBuild, $table); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function multiple() |
48 | 48 | { |
49 | - return new QueryInsertMultiple( $this->queryBuild, $this->queryStructure->getElement( QueryStructure::TABLE ) ); |
|
49 | + return new QueryInsertMultiple($this->queryBuild, $this->queryStructure->getElement(QueryStructure::TABLE)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param bool|int $replacement |
54 | 54 | * @return mixed|string |
55 | 55 | */ |
56 | - public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
56 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
57 | 57 | { |
58 | 58 | $syntax = array(); |
59 | 59 | |
@@ -70,26 +70,26 @@ discard block |
||
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 | 88 | $syntax[] = $this->getSettingFieldsSyntax(); |
89 | 89 | |
90 | - $syntax = implode( ' ', $syntax ); |
|
90 | + $syntax = implode(' ', $syntax); |
|
91 | 91 | |
92 | - return $this->getSyntaxReplace( $syntax, $replacement ); |
|
92 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | return DbService::getInstance()->query( |
100 | 100 | $this->getSyntax(), |
101 | - $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) |
|
101 | + $this->queryStructure->getElement(QueryStructure::BIND_PARAMS) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * @param QueryBuild $queryBuild |
41 | 41 | * @param string $table |
42 | 42 | */ |
43 | - public function __construct( QueryBuild $queryBuild, $table = null ) |
|
43 | + public function __construct(QueryBuild $queryBuild, $table = null) |
|
44 | 44 | { |
45 | - parent::__construct( $queryBuild, $table ); |
|
45 | + parent::__construct($queryBuild, $table); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
|
48 | + public function getSyntax($replacement = self::REPLACEMENT_NONE) |
|
49 | 49 | { |
50 | 50 | $syntax = array(); |
51 | 51 | |
@@ -62,12 +62,12 @@ discard block |
||
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 |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | $syntax[] = $this->getLimitSyntax(); |
86 | 86 | |
87 | - $syntax = implode( ' ', $syntax ); |
|
87 | + $syntax = implode(' ', $syntax); |
|
88 | 88 | |
89 | - return $this->getSyntaxReplace( $syntax, $replacement ); |
|
89 | + return $this->getSyntaxReplace($syntax, $replacement); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | { |
98 | 98 | |
99 | 99 | if ( |
100 | - $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && |
|
101 | - !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) |
|
100 | + $this->queryStructure->getElement((QueryStructure::WHERE_TRIGGER)) && |
|
101 | + !count($this->queryStructure->getElement(QueryStructure::WHERE)) |
|
102 | 102 | ) |
103 | - throw new QueryException( 'Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER ); |
|
103 | + throw new QueryException('Where or Having clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER); |
|
104 | 104 | |
105 | 105 | return DbService::getInstance()->query( |
106 | 106 | $this->getSyntax(), |
107 | - $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) |
|
107 | + $this->queryStructure->getElement(QueryStructure::BIND_PARAMS) |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | } |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | * @param string|QuerySelect $table |
64 | 64 | * @throws QueryException |
65 | 65 | */ |
66 | - public function __construct( QueryBuild $queryBuild, $table = '' ) |
|
66 | + public function __construct(QueryBuild $queryBuild, $table = '') |
|
67 | 67 | { |
68 | 68 | |
69 | - $table = $this->validateTable( $table ); |
|
69 | + $table = $this->validateTable($table); |
|
70 | 70 | |
71 | 71 | $this->queryBuild = $queryBuild; |
72 | 72 | $this->queryStructure = new QueryStructure(); |
73 | - $this->queryStructure->setElement( QueryStructure::TABLE, $table ); |
|
74 | - $this->queryStructure->setElement( QueryStructure::STATEMENT, $this->statement ); |
|
75 | - $this->queryStructure->setElement( QueryStructure::QUERY_TYPE, $this->queryBuild->getType() ); |
|
73 | + $this->queryStructure->setElement(QueryStructure::TABLE, $table); |
|
74 | + $this->queryStructure->setElement(QueryStructure::STATEMENT, $this->statement); |
|
75 | + $this->queryStructure->setElement(QueryStructure::QUERY_TYPE, $this->queryBuild->getType()); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getBindParams() |
83 | 83 | { |
84 | - return $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ); |
|
84 | + return $this->queryStructure->getElement(QueryStructure::BIND_PARAMS); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 |