@@ -28,6 +28,9 @@ class Connection implements IConnection
2828 /** @var array Current connection configuration */
2929 private $ config ;
3030
31+ /** @var string[] resultset formats */
32+ private $ formats ;
33+
3134 /** @var Driver|null */
3235 private $ driver ;
3336
@@ -65,9 +68,14 @@ public function __construct(array $config, string $name = null)
6568 Helpers::alias ($ config , 'result|formatDateTime ' , 'resultDateTime ' );
6669 $ config ['driver ' ] = $ config ['driver ' ] ?? 'mysqli ' ;
6770 $ config ['name ' ] = $ name ;
68- $ config ['result ' ]['formatJson ' ] = $ config ['result ' ]['formatJson ' ] ?? 'array ' ;
6971 $ this ->config = $ config ;
7072
73+ $ this ->formats = [
74+ Type::DATE => $ this ->config ['result ' ]['formatDate ' ],
75+ Type::DATETIME => $ this ->config ['result ' ]['formatDateTime ' ],
76+ Type::JSON => $ this ->config ['result ' ]['formatJson ' ] ?? 'array ' ,
77+ ];
78+
7179 // profiler
7280 if (isset ($ config ['profiler ' ]['file ' ]) && (!isset ($ config ['profiler ' ]['run ' ]) || $ config ['profiler ' ]['run ' ])) {
7381 $ filter = $ config ['profiler ' ]['filter ' ] ?? Event::QUERY ;
@@ -391,10 +399,7 @@ public function rollback(string $savepoint = null): void
391399 */
392400 public function createResultSet (ResultDriver $ resultDriver ): Result
393401 {
394- $ res = new Result ($ resultDriver );
395- return $ res ->setFormat (Type::DATE , $ this ->config ['result ' ]['formatDate ' ])
396- ->setFormat (Type::DATETIME , $ this ->config ['result ' ]['formatDateTime ' ])
397- ->setFormat (Type::JSON , $ this ->config ['result ' ]['formatJson ' ]);
402+ return new Result ($ resultDriver , $ this ->formats );
398403 }
399404
400405
0 commit comments