Passed
Push — master ( 650973...6b115b )
by Adrian
01:48
created
sample/select.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	->whereIn( 'officeCode', [ 2, 3, 4 ] )
23 23
 	->count();
24 24
 
25
-$desc = QueryBuild::query('show tables');
25
+$desc = QueryBuild::query( 'show tables' );
26 26
 
27 27
 echo "<pre>" . print_r( $count->execute(), 1 ) . "</pre>";
28 28
 echo "<pre>" . print_r( $desc->execute(), 1 ) . "</pre>";
Please login to merge, or discard this patch.
src/DB/DbService.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * @var array
48 48
 	 */
49
-	private $parameters = [];
49
+	private $parameters = [ ];
50 50
 
51 51
 	/**
52 52
 	 * @var string;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		$column = null;
126 126
 
127 127
 		foreach ( $Columns as $cells ) {
128
-			$column[] = $cells[ 0 ];
128
+			$column[ ] = $cells[ 0 ];
129 129
 		}
130 130
 
131 131
 		return $column;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param array $parameters
210 210
 	 * @throws DbException
211 211
 	 */
212
-	private function queryInit( $query, $parameters = [] )
212
+	private function queryInit( $query, $parameters = [ ] )
213 213
 	{
214 214
 		$this->lastStatement = self::getQueryStatement( $query );
215 215
 		$this->createPdoConnection();
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 			 * Prepare query
221 221
 			 */
222 222
 			$this->sQuery = $this->pdo->prepare( $query );
223
-			$this->prepareParams($parameters);
223
+			$this->prepareParams( $parameters );
224 224
 			$this->pdoBindValues();
225 225
 			$this->sQuery->execute();
226 226
 			if ( DbConfig::getInstance()->isEnableLogQueryDuration() ) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			$this->bindMore( $parameters );
247 247
 		else
248 248
 			foreach ( $parameters as $key => $val )
249
-				$this->parameters[] = array( $key + 1, $val );
249
+				$this->parameters[ ] = array( $key + 1, $val );
250 250
 	}
251 251
 
252 252
 	private function pdoBindValues()
Please login to merge, or discard this patch.
Braces   +25 added lines, -22 removed lines patch added patch discarded remove patch
@@ -117,8 +117,9 @@  discard block
 block discarded – undo
117 117
 	{
118 118
 		$this->queryInit( $query, $params );
119 119
 
120
-		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN )
121
-			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
120
+		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) {
121
+					return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
122
+		}
122 123
 
123 124
 		$Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM );
124 125
 
@@ -141,8 +142,9 @@  discard block
 block discarded – undo
141 142
 	{
142 143
 		$this->queryInit( $query, $params );
143 144
 
144
-		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN )
145
-			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
145
+		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) {
146
+					return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
147
+		}
146 148
 
147 149
 		$result = $this->sQuery->fetch( $fetchmode );
148 150
 		$this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued,
@@ -159,8 +161,9 @@  discard block
 block discarded – undo
159 161
 	{
160 162
 		$this->queryInit( $query, $params );
161 163
 
162
-		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN )
163
-			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
164
+		if ( $this->lastStatement === self::QUERY_TYPE_EXPLAIN ) {
165
+					return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
166
+		}
164 167
 
165 168
 		$result = $this->sQuery->fetchColumn();
166 169
 		$this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued
@@ -242,11 +245,12 @@  discard block
 block discarded – undo
242 245
 
243 246
 	private function prepareParams( array $parameters )
244 247
 	{
245
-		if ( self::isArrayAssoc( $parameters ) )
246
-			$this->bindMore( $parameters );
247
-		else
248
-			foreach ( $parameters as $key => $val )
248
+		if ( self::isArrayAssoc( $parameters ) ) {
249
+					$this->bindMore( $parameters );
250
+		} else {
251
+					foreach ( $parameters as $key => $val )
249 252
 				$this->parameters[] = array( $key + 1, $val );
253
+		}
250 254
 	}
251 255
 
252 256
 	private function pdoBindValues()
@@ -254,14 +258,11 @@  discard block
 block discarded – undo
254 258
 		foreach ( $this->parameters as $param => $value ) {
255 259
 			if ( is_int( $value[ 1 ] ) ) {
256 260
 				$type = \PDO::PARAM_INT;
257
-			}
258
-			elseif ( is_bool( $value[ 1 ] ) ) {
261
+			} elseif ( is_bool( $value[ 1 ] ) ) {
259 262
 				$type = \PDO::PARAM_BOOL;
260
-			}
261
-			elseif ( is_null( $value[ 1 ] ) ) {
263
+			} elseif ( is_null( $value[ 1 ] ) ) {
262 264
 				$type = \PDO::PARAM_NULL;
263
-			}
264
-			else {
265
+			} else {
265 266
 				$type = \PDO::PARAM_STR;
266 267
 			}
267 268
 			$this->sQuery->bindValue( $value[ 0 ], $value[ 1 ], $type );
@@ -305,10 +306,11 @@  discard block
 block discarded – undo
305 306
 	{
306 307
 		$queryString = trim( $queryString );
307 308
 
308
-		if ( preg_match( '/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches ) )
309
-			return strtoupper( $matches[ 1 ] );
310
-		else
311
-			return self::QUERY_TYPE_OTHER;
309
+		if ( preg_match( '/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches ) ) {
310
+					return strtoupper( $matches[ 1 ] );
311
+		} else {
312
+					return self::QUERY_TYPE_OTHER;
313
+		}
312 314
 	}
313 315
 
314 316
 	/**
@@ -317,8 +319,9 @@  discard block
 block discarded – undo
317 319
 	 */
318 320
 	public static function isArrayAssoc( array $arr )
319 321
 	{
320
-		if ( array() === $arr )
321
-			return false;
322
+		if ( array() === $arr ) {
323
+					return false;
324
+		}
322 325
 
323 326
 		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
324 327
 	}
Please login to merge, or discard this patch.