@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * @return bool |
|
| 179 | + * @return integer |
|
| 180 | 180 | */ |
| 181 | 181 | public function getFoundRows() { |
| 182 | 182 | return $this->foundRows; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * @param callable $callback |
| 226 | 226 | * @param int $mode |
| 227 | - * @param mixed $arg0 |
|
| 227 | + * @param string $arg0 |
|
| 228 | 228 | * @return mixed |
| 229 | 229 | * @throws \Exception |
| 230 | 230 | */ |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | /** |
| 259 | 259 | * @param callable $callback |
| 260 | 260 | * @param int $mode |
| 261 | - * @param mixed $arg0 |
|
| 261 | + * @param string $arg0 |
|
| 262 | 262 | * @return Generator|YieldPolyfillIterator|mixed[] |
| 263 | 263 | */ |
| 264 | 264 | private function fetchLazy($callback, $mode, $arg0 = null) { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | /** |
| 279 | 279 | * @param callable $callback |
| 280 | 280 | * @param int $mode |
| 281 | - * @param mixed $arg0 |
|
| 281 | + * @param string $arg0 |
|
| 282 | 282 | * @return mixed |
| 283 | 283 | * @throws \Exception |
| 284 | 284 | */ |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @return mixed[] |
| 118 | 118 | */ |
| 119 | 119 | public function fetchKeyValue($treatValueAsArray = false) { |
| 120 | - return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) { |
|
| 121 | - if($treatValueAsArray) { |
|
| 120 | + return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) { |
|
| 121 | + if ($treatValueAsArray) { |
|
| 122 | 122 | $rows = $statement->fetchAll(\PDO::FETCH_ASSOC); |
| 123 | 123 | $result = array(); |
| 124 | - foreach($rows as $row) { |
|
| 124 | + foreach ($rows as $row) { |
|
| 125 | 125 | list($key) = array_values($row); |
| 126 | 126 | $result[$key] = $row; |
| 127 | 127 | } |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | public function fetchGroups(array $fields) { |
| 139 | 139 | $rows = $this->fetchRows(); |
| 140 | 140 | $result = array(); |
| 141 | - foreach($rows as $row) { |
|
| 141 | + foreach ($rows as $row) { |
|
| 142 | 142 | $tmp = &$result; |
| 143 | - foreach($fields as $field) { |
|
| 143 | + foreach ($fields as $field) { |
|
| 144 | 144 | $value = $row[$field]; |
| 145 | - if(!array_key_exists($value, $tmp)) { |
|
| 145 | + if (!array_key_exists($value, $tmp)) { |
|
| 146 | 146 | $tmp[$value] = []; |
| 147 | 147 | } |
| 148 | 148 | $tmp = &$tmp[$value]; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @return string[] |
| 157 | 157 | */ |
| 158 | 158 | public function fetchArray() { |
| 159 | - return $this->createTempStatement(function (QueryStatement $stmt) { |
|
| 159 | + return $this->createTempStatement(function(QueryStatement $stmt) { |
|
| 160 | 160 | return $stmt->fetchAll(\PDO::FETCH_COLUMN); |
| 161 | 161 | }); |
| 162 | 162 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | * @return null|bool|string|int|float |
| 167 | 167 | */ |
| 168 | 168 | public function fetchValue($default = null) { |
| 169 | - return $this->createTempStatement(function (QueryStatement $stmt) use ($default) { |
|
| 169 | + return $this->createTempStatement(function(QueryStatement $stmt) use ($default) { |
|
| 170 | 170 | $result = $stmt->fetch(\PDO::FETCH_NUM); |
| 171 | - if($result !== false) { |
|
| 171 | + if ($result !== false) { |
|
| 172 | 172 | return $result[0]; |
| 173 | 173 | } |
| 174 | 174 | return $default; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $query = $this->__toString(); |
| 209 | 209 | $statement = $db->prepare($query); |
| 210 | 210 | $statement->execute($this->values); |
| 211 | - if($this->getCalcFoundRows()) { |
|
| 211 | + if ($this->getCalcFoundRows()) { |
|
| 212 | 212 | $this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn(); |
| 213 | 213 | } |
| 214 | 214 | return $statement; |
@@ -229,20 +229,20 @@ discard block |
||
| 229 | 229 | * @throws \Exception |
| 230 | 230 | */ |
| 231 | 231 | private function fetchAll($callback, $mode, $arg0 = null) { |
| 232 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 232 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 233 | 233 | $statement->setFetchMode($mode, $arg0); |
| 234 | 234 | $data = $statement->fetchAll(); |
| 235 | - if($this->preserveTypes) { |
|
| 235 | + if ($this->preserveTypes) { |
|
| 236 | 236 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 237 | - foreach($data as &$row) { |
|
| 237 | + foreach ($data as &$row) { |
|
| 238 | 238 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | - if($callback !== null) { |
|
| 242 | - return call_user_func(function ($resultData = []) use ($data, $callback) { |
|
| 243 | - foreach($data as $row) { |
|
| 241 | + if ($callback !== null) { |
|
| 242 | + return call_user_func(function($resultData = []) use ($data, $callback) { |
|
| 243 | + foreach ($data as $row) { |
|
| 244 | 244 | $result = $callback($row); |
| 245 | - if($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 245 | + if ($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 246 | 246 | $resultData[] = $result; |
| 247 | 247 | } else { |
| 248 | 248 | $resultData[] = $row; |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | * @return Generator|YieldPolyfillIterator|mixed[] |
| 263 | 263 | */ |
| 264 | 264 | private function fetchLazy($callback, $mode, $arg0 = null) { |
| 265 | - if(version_compare(PHP_VERSION, '5.5', '<')) { |
|
| 266 | - return new YieldPolyfillIterator($callback, $this->preserveTypes, function () use ($mode, $arg0) { |
|
| 265 | + if (version_compare(PHP_VERSION, '5.5', '<')) { |
|
| 266 | + return new YieldPolyfillIterator($callback, $this->preserveTypes, function() use ($mode, $arg0) { |
|
| 267 | 267 | $statement = $this->createStatement(); |
| 268 | 268 | $statement->setFetchMode($mode, $arg0); |
| 269 | 269 | return $statement; |
@@ -283,19 +283,19 @@ discard block |
||
| 283 | 283 | * @throws \Exception |
| 284 | 284 | */ |
| 285 | 285 | private function fetch($callback, $mode, $arg0 = null) { |
| 286 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 286 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 287 | 287 | $statement->setFetchMode($mode, $arg0); |
| 288 | 288 | $row = $statement->fetch(); |
| 289 | - if(!is_array($row)) { |
|
| 289 | + if (!is_array($row)) { |
|
| 290 | 290 | return []; |
| 291 | 291 | } |
| 292 | - if($this->preserveTypes) { |
|
| 292 | + if ($this->preserveTypes) { |
|
| 293 | 293 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 294 | 294 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 295 | 295 | } |
| 296 | - if($callback !== null) { |
|
| 296 | + if ($callback !== null) { |
|
| 297 | 297 | $result = $callback($row); |
| 298 | - if($result !== null) { |
|
| 298 | + if ($result !== null) { |
|
| 299 | 299 | $row = $result; |
| 300 | 300 | } |
| 301 | 301 | } |