@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | * @return array[] |
57 | 57 | */ |
58 | 58 | public function fetchRows(\Closure $callback = null) { |
59 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback) { |
|
59 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback) { |
|
60 | 60 | $data = $statement->fetchAll(\PDO::FETCH_ASSOC); |
61 | - if($this->preserveTypes) { |
|
61 | + if ($this->preserveTypes) { |
|
62 | 62 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
63 | - foreach($data as &$row) { |
|
63 | + foreach ($data as &$row) { |
|
64 | 64 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
65 | 65 | } |
66 | 66 | } |
67 | - if($callback !== null) { |
|
67 | + if ($callback !== null) { |
|
68 | 68 | $data = array_map($callback, $data); |
69 | 69 | } |
70 | 70 | return $data; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return array[]|\Generator |
77 | 77 | */ |
78 | 78 | public function fetchRowsLazy(\Closure $callback = null) { |
79 | - if(version_compare(PHP_VERSION, '5.5', '<=')) { |
|
79 | + if (version_compare(PHP_VERSION, '5.5', '<=')) { |
|
80 | 80 | return $this->fetchRows($callback); |
81 | 81 | } |
82 | 82 | $statement = $this->createStatement(); |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * @return string[] |
89 | 89 | */ |
90 | 90 | public function fetchRow() { |
91 | - return $this->createTempStatement(function (QueryStatement $statement) { |
|
91 | + return $this->createTempStatement(function(QueryStatement $statement) { |
|
92 | 92 | $row = $statement->fetch(\PDO::FETCH_ASSOC); |
93 | - if(!is_array($row)) { |
|
93 | + if (!is_array($row)) { |
|
94 | 94 | return array(); |
95 | 95 | } |
96 | - if($this->preserveTypes) { |
|
96 | + if ($this->preserveTypes) { |
|
97 | 97 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
98 | 98 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
99 | 99 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * @return mixed[] |
107 | 107 | */ |
108 | 108 | public function fetchKeyValue($treatValueAsArray = false) { |
109 | - return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) { |
|
110 | - if($treatValueAsArray) { |
|
109 | + return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) { |
|
110 | + if ($treatValueAsArray) { |
|
111 | 111 | $rows = $statement->fetchAll(\PDO::FETCH_ASSOC); |
112 | 112 | $result = array(); |
113 | - foreach($rows as $row) { |
|
113 | + foreach ($rows as $row) { |
|
114 | 114 | list($key) = array_values($row); |
115 | 115 | $result[$key] = $row; |
116 | 116 | } |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | public function fetchGroups(array $fields) { |
128 | 128 | $rows = $this->fetchRows(); |
129 | 129 | $result = array(); |
130 | - foreach($rows as $row) { |
|
130 | + foreach ($rows as $row) { |
|
131 | 131 | $tmp = &$result; |
132 | - foreach($fields as $field) { |
|
132 | + foreach ($fields as $field) { |
|
133 | 133 | $value = $row[$field]; |
134 | - if(!array_key_exists($value, $tmp)) { |
|
134 | + if (!array_key_exists($value, $tmp)) { |
|
135 | 135 | $tmp[$value] = []; |
136 | 136 | } |
137 | 137 | $tmp = &$tmp[$value]; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return string[] |
146 | 146 | */ |
147 | 147 | public function fetchArray() { |
148 | - return $this->createTempStatement(function (QueryStatement $stmt) { |
|
148 | + return $this->createTempStatement(function(QueryStatement $stmt) { |
|
149 | 149 | return $stmt->fetchAll(\PDO::FETCH_COLUMN); |
150 | 150 | }); |
151 | 151 | } |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * @return null|bool|string|int|float |
156 | 156 | */ |
157 | 157 | public function fetchValue($default = null) { |
158 | - return $this->createTempStatement(function (QueryStatement $stmt) use ($default) { |
|
158 | + return $this->createTempStatement(function(QueryStatement $stmt) use ($default) { |
|
159 | 159 | $result = $stmt->fetch(\PDO::FETCH_NUM); |
160 | - if($result !== false) { |
|
160 | + if ($result !== false) { |
|
161 | 161 | return $result[0]; |
162 | 162 | } |
163 | 163 | return $default; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $query = $this->__toString(); |
198 | 198 | $statement = $db->prepare($query); |
199 | 199 | $statement->execute($this->values); |
200 | - if($this->getCalcFoundRows()) { |
|
200 | + if ($this->getCalcFoundRows()) { |
|
201 | 201 | $this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn(); |
202 | 202 | } |
203 | 203 | return $statement; |