From 98563d8165449645a9189e2b574eb509bd433736 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 8 Oct 2020 17:56:27 +0200 Subject: [PATCH] Connection: added option [result][normalize] [Closes #367] --- src/Dibi/Connection.php | 3 ++- src/Dibi/Result.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php index b73703fc..ce41fa6e 100644 --- a/src/Dibi/Connection.php +++ b/src/Dibi/Connection.php @@ -45,6 +45,7 @@ class Connection implements IConnection * Connection options: (see driver-specific options too) * - lazy (bool) => if true, connection will be established only when required * - result (array) => result set options + * - normalize => normalizes result fields (default: true) * - formatDateTime => date-time format * empty for decoding as Dibi\DateTime (default) * "..." formatted according to given format, see https://www.php.net/manual/en/datetime.format.php @@ -401,7 +402,7 @@ class Connection implements IConnection */ public function createResultSet(ResultDriver $resultDriver): Result { - return (new Result($resultDriver)) + return (new Result($resultDriver, $this->config['result']['normalize'] ?? true)) ->setFormats($this->formats); } diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php index d998ba77..00ab70bd 100644 --- a/src/Dibi/Result.php +++ b/src/Dibi/Result.php @@ -41,10 +41,12 @@ class Result implements IDataSource private $formats = []; - public function __construct(ResultDriver $driver) + public function __construct(ResultDriver $driver, bool $normalize = true) { $this->driver = $driver; - $this->detectTypes(); + if ($normalize) { + $this->detectTypes(); + } }