summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/SQLite3/Result.php')
-rw-r--r--vendor/doctrine/dbal/src/Driver/SQLite3/Result.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php
new file mode 100644
index 0000000..61b42d3
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php
@@ -0,0 +1,88 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\SQLite3;
6
7use Doctrine\DBAL\Driver\FetchUtils;
8use Doctrine\DBAL\Driver\Result as ResultInterface;
9use SQLite3Result;
10
11use const SQLITE3_ASSOC;
12use const SQLITE3_NUM;
13
14final class Result implements ResultInterface
15{
16 private ?SQLite3Result $result;
17
18 /** @internal The result can be only instantiated by its driver connection or statement. */
19 public function __construct(SQLite3Result $result, private readonly int $changes)
20 {
21 $this->result = $result;
22 }
23
24 public function fetchNumeric(): array|false
25 {
26 if ($this->result === null) {
27 return false;
28 }
29
30 return $this->result->fetchArray(SQLITE3_NUM);
31 }
32
33 public function fetchAssociative(): array|false
34 {
35 if ($this->result === null) {
36 return false;
37 }
38
39 return $this->result->fetchArray(SQLITE3_ASSOC);
40 }
41
42 public function fetchOne(): mixed
43 {
44 return FetchUtils::fetchOne($this);
45 }
46
47 /** @inheritDoc */
48 public function fetchAllNumeric(): array
49 {
50 return FetchUtils::fetchAllNumeric($this);
51 }
52
53 /** @inheritDoc */
54 public function fetchAllAssociative(): array
55 {
56 return FetchUtils::fetchAllAssociative($this);
57 }
58
59 /** @inheritDoc */
60 public function fetchFirstColumn(): array
61 {
62 return FetchUtils::fetchFirstColumn($this);
63 }
64
65 public function rowCount(): int
66 {
67 return $this->changes;
68 }
69
70 public function columnCount(): int
71 {
72 if ($this->result === null) {
73 return 0;
74 }
75
76 return $this->result->numColumns();
77 }
78
79 public function free(): void
80 {
81 if ($this->result === null) {
82 return;
83 }
84
85 $this->result->finalize();
86 $this->result = null;
87 }
88}