@@ -21,7 +21,7 @@ |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | protected function buildOffset($query) { |
24 | - if($this->offset !== null) { |
|
24 | + if ($this->offset !== null) { |
|
25 | 25 | $query .= "OFFSET\n\t{$this->offset}\n"; |
26 | 26 | } |
27 | 27 | return $query; |
@@ -8,8 +8,8 @@ |
||
8 | 8 | * @return array |
9 | 9 | */ |
10 | 10 | public static function convertValues(array $row, array $columnDefinitions) { |
11 | - foreach($row as $key => &$value) { |
|
12 | - if($value !== null) { |
|
11 | + foreach ($row as $key => &$value) { |
|
12 | + if ($value !== null) { |
|
13 | 13 | $value = self::convertValue($value, $columnDefinitions[$key]); |
14 | 14 | } |
15 | 15 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | protected function buildLimit($query, $offset = null) { |
30 | 30 | $limit = $this->limit; |
31 | - if($limit === null && $offset !== null) { |
|
31 | + if ($limit === null && $offset !== null) { |
|
32 | 32 | $limit = '18446744073709551615'; |
33 | 33 | } |
34 | - if($limit !== null) { |
|
34 | + if ($limit !== null) { |
|
35 | 35 | $query .= "LIMIT\n\t{$limit}\n"; |
36 | 36 | } |
37 | 37 | return $query; |
@@ -11,16 +11,16 @@ |
||
11 | 11 | */ |
12 | 12 | public function __construct($spec, $sortFieldsSpec) { |
13 | 13 | $expressions = []; |
14 | - foreach($spec as $specReference => $dbExpr) { |
|
15 | - if(is_int($specReference)) { |
|
14 | + foreach ($spec as $specReference => $dbExpr) { |
|
15 | + if (is_int($specReference)) { |
|
16 | 16 | $specReference = $dbExpr; |
17 | 17 | } |
18 | 18 | $expressions[$specReference] = $dbExpr; |
19 | 19 | } |
20 | - foreach($sortFieldsSpec as $sortFieldSpec) { |
|
21 | - if(array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) { |
|
20 | + foreach ($sortFieldsSpec as $sortFieldSpec) { |
|
21 | + if (array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) { |
|
22 | 22 | $direction = 'ASC'; |
23 | - if(array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') { |
|
23 | + if (array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') { |
|
24 | 24 | $direction = 'DESC'; |
25 | 25 | } |
26 | 26 | $this->fields[] = [ |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | public static function getFieldTypes(QueryStatement $statement) { |
12 | 12 | $fieldTypes = []; |
13 | - for($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
13 | + for ($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
14 | 14 | $fieldTypes[$column['name']] = self::getTypeFromNativeType($column['native_type']); |
15 | 15 | } |
16 | 16 | return $fieldTypes; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function run(array $params = []) { |
26 | 26 | $this->query->execute($params); |
27 | 27 | $response = $this->query->getStatement()->rowCount(); |
28 | - if($this->callbackFn !== null) { |
|
28 | + if ($this->callbackFn !== null) { |
|
29 | 29 | $response = call_user_func($this->callbackFn, $response); |
30 | 30 | } |
31 | 31 | return $response; |
@@ -22,16 +22,16 @@ |
||
22 | 22 | * @return Generator|mixed[] |
23 | 23 | */ |
24 | 24 | public function generate(QueryStatement $statement, Closure $callback = null) { |
25 | - while($row = $statement->fetch()) { |
|
26 | - if($this->preserveTypes) { |
|
25 | + while ($row = $statement->fetch()) { |
|
26 | + if ($this->preserveTypes) { |
|
27 | 27 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
28 | 28 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
29 | 29 | } |
30 | - if($callback !== null) { |
|
30 | + if ($callback !== null) { |
|
31 | 31 | $result = $callback($row); |
32 | - if($result instanceof DBIgnoreRow) { |
|
32 | + if ($result instanceof DBIgnoreRow) { |
|
33 | 33 | // Do nothing in this case |
34 | - } elseif($result !== null) { |
|
34 | + } elseif ($result !== null) { |
|
35 | 35 | yield $result; |
36 | 36 | } else { |
37 | 37 | yield $row; |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function setFetchMode($mode, $arg0 = null, array $arg1 = null) { |
49 | 49 | $args = [$mode]; |
50 | - if($arg0 !== null) { |
|
50 | + if ($arg0 !== null) { |
|
51 | 51 | $args[] = $arg0; |
52 | 52 | } |
53 | - if($arg1 !== null) { |
|
53 | + if ($arg1 !== null) { |
|
54 | 54 | $args[] = $arg1; |
55 | 55 | } |
56 | 56 | $this->statement->setFetchMode(...$args); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $timer = microtime(true); |
68 | 68 | $response = $this->statement->execute($params); |
69 | 69 | $this->queryLoggers->log($this->query, microtime(true)-$timer); |
70 | - if(!$response) { |
|
70 | + if (!$response) { |
|
71 | 71 | throw new SqlException('Execution returned with "false".'); |
72 | 72 | } |
73 | 73 | }); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []) { |
84 | 84 | return $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) { |
85 | - if($fetchArgument !== null) { |
|
85 | + if ($fetchArgument !== null) { |
|
86 | 86 | return $this->statement->fetchAll($fetchStyle, $fetchArgument, $ctorArgs); |
87 | 87 | } |
88 | 88 | return $this->statement->fetchAll($fetchStyle); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * @return $this |
62 | 62 | */ |
63 | 63 | public function setExpr($expr, ...$args) { |
64 | - if(count($args) > 0) { |
|
64 | + if (count($args) > 0) { |
|
65 | 65 | $this->fields[] = func_get_args(); |
66 | 66 | } else { |
67 | 67 | $this->fields[] = $expr; |