|
18 | 18 | */ |
19 | 19 | class SQLiteEngine implements Engine |
20 | 20 | { |
21 | | - private Nette\Database\Connection $connection; |
22 | | - private string $fmtDateTime; |
| 21 | + public string $formatDateTime = 'U'; |
23 | 22 |
|
24 | 23 |
|
25 | | - public function initialize(Nette\Database\Connection $connection, array $options): void |
26 | | - { |
27 | | - $this->connection = $connection; |
28 | | - $this->fmtDateTime = $options['formatDateTime'] ?? 'U'; |
| 24 | + public function __construct( |
| 25 | + private readonly Nette\Database\Connection $connection, |
| 26 | + ) { |
29 | 27 | } |
30 | 28 |
|
31 | 29 |
|
@@ -72,7 +70,7 @@ public function delimite(string $name): string |
72 | 70 |
|
73 | 71 | public function formatDateTime(\DateTimeInterface $value): string |
74 | 72 | { |
75 | | - return $value->format($this->fmtDateTime); |
| 73 | + return $value->format($this->formatDateTime); |
76 | 74 | } |
77 | 75 |
|
78 | 76 |
|
@@ -235,7 +233,7 @@ public function getColumnTypes(\PDOStatement $statement): array |
235 | 233 | for ($col = 0; $col < $count; $col++) { |
236 | 234 | $meta = $statement->getColumnMeta($col); |
237 | 235 | if (isset($meta['sqlite:decl_type'])) { |
238 | | - $types[$meta['name']] = $this->fmtDateTime === 'U' && in_array($meta['sqlite:decl_type'], ['DATE', 'DATETIME'], strict: true) |
| 236 | + $types[$meta['name']] = $this->formatDateTime === 'U' && in_array($meta['sqlite:decl_type'], ['DATE', 'DATETIME'], strict: true) |
239 | 237 | ? Nette\Database\IStructure::FIELD_UNIX_TIMESTAMP |
240 | 238 | : Nette\Database\Helpers::detectType($meta['sqlite:decl_type']); |
241 | 239 | } elseif (isset($meta['native_type'])) { |
|
0 commit comments