Skip to content

Commit

Permalink
Connection: added option [result][normalize] [Closes #367]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 2, 2020
1 parent 25b3c4c commit a9b3683
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Dibi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -401,7 +402,7 @@ public function rollback(string $savepoint = null): void
*/
public function createResultSet(ResultDriver $resultDriver): Result
{
return (new Result($resultDriver))
return (new Result($resultDriver, $this->config['result']['normalize'] ?? true))
->setFormats($this->formats);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Dibi/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}


Expand Down

0 comments on commit a9b3683

Please sign in to comment.