summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Driver/FetchUtils.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/FetchUtils.php')
-rw-r--r--vendor/doctrine/dbal/src/Driver/FetchUtils.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/FetchUtils.php b/vendor/doctrine/dbal/src/Driver/FetchUtils.php
new file mode 100644
index 0000000..eda5211
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/FetchUtils.php
@@ -0,0 +1,69 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver;
6
7/** @internal */
8final class FetchUtils
9{
10 /** @throws Exception */
11 public static function fetchOne(Result $result): mixed
12 {
13 $row = $result->fetchNumeric();
14
15 if ($row === false) {
16 return false;
17 }
18
19 return $row[0];
20 }
21
22 /**
23 * @return list<list<mixed>>
24 *
25 * @throws Exception
26 */
27 public static function fetchAllNumeric(Result $result): array
28 {
29 $rows = [];
30
31 while (($row = $result->fetchNumeric()) !== false) {
32 $rows[] = $row;
33 }
34
35 return $rows;
36 }
37
38 /**
39 * @return list<array<string,mixed>>
40 *
41 * @throws Exception
42 */
43 public static function fetchAllAssociative(Result $result): array
44 {
45 $rows = [];
46
47 while (($row = $result->fetchAssociative()) !== false) {
48 $rows[] = $row;
49 }
50
51 return $rows;
52 }
53
54 /**
55 * @return list<mixed>
56 *
57 * @throws Exception
58 */
59 public static function fetchFirstColumn(Result $result): array
60 {
61 $rows = [];
62
63 while (($row = $result->fetchOne()) !== false) {
64 $rows[] = $row;
65 }
66
67 return $rows;
68 }
69}