Skip to content

Commit 138139d

Browse files
committed
Connection: added option [result][normalize] [Closes #367]
1 parent 63ecd64 commit 138139d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Dibi/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Connection implements IConnection
4545
* Connection options: (see driver-specific options too)
4646
* - lazy (bool) => if true, connection will be established only when required
4747
* - result (array) => result set options
48+
* - normalize => normalizes result fields (default: true)
4849
* - formatDateTime => date-time format
4950
* empty for decoding as Dibi\DateTime (default)
5051
* "..." formatted according to given format, see https://www.php.net/manual/en/datetime.format.php
@@ -401,7 +402,7 @@ public function rollback(string $savepoint = null): void
401402
*/
402403
public function createResultSet(ResultDriver $resultDriver): Result
403404
{
404-
return (new Result($resultDriver))
405+
return (new Result($resultDriver, $this->config['result']['normalize'] ?? true))
405406
->setFormats($this->formats);
406407
}
407408

src/Dibi/Result.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ class Result implements IDataSource
4141
private $formats = [];
4242

4343

44-
public function __construct(ResultDriver $driver)
44+
public function __construct(ResultDriver $driver, bool $normalize = true)
4545
{
4646
$this->driver = $driver;
47-
$this->detectTypes();
47+
if ($normalize) {
48+
$this->detectTypes();
49+
}
4850
}
4951

5052

0 commit comments

Comments
 (0)