File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ class Connection implements IConnection
5050 * empty for decoding as Dibi\DateTime (default)
5151 * "..." formatted according to given format, see https://www.php.net/manual/en/datetime.format.php
5252 * "native" for leaving value as is
53+ * - formatTimeInterval => time-interval format
54+ * empty for decoding as DateInterval (default)
55+ * "..." formatted according to given format, see https://www.php.net/manual/en/dateinterval.format.php
56+ * "native" for leaving value as is
5357 * - formatJson => json format
5458 * "array" for decoding json as an array (default)
5559 * "object" for decoding json as \stdClass
@@ -77,6 +81,7 @@ public function __construct(array $config, string $name = null)
7781 Type::DATE => $ this ->config ['result ' ]['formatDate ' ],
7882 Type::DATETIME => $ this ->config ['result ' ]['formatDateTime ' ],
7983 Type::JSON => $ this ->config ['result ' ]['formatJson ' ] ?? 'array ' ,
84+ Type::TIME_INTERVAL => $ this ->config ['result ' ]['formatTimeInterval ' ] ?? null ,
8085 ];
8186
8287 // profiler
Original file line number Diff line number Diff line change @@ -498,8 +498,9 @@ private function normalize(array &$row): void
498498
499499 } elseif ($ type === Type::TIME_INTERVAL ) {
500500 preg_match ('#^(-?)(\d+)\D(\d+)\D(\d+)\z# ' , $ value , $ m );
501- $ row [$ key ] = new \DateInterval ("PT $ m [2 ]H $ m [3 ]M $ m [4 ]S " );
502- $ row [$ key ]->invert = (int ) (bool ) $ m [1 ];
501+ $ value = new \DateInterval ("PT $ m [2 ]H $ m [3 ]M $ m [4 ]S " );
502+ $ value ->invert = (int ) (bool ) $ m [1 ];
503+ $ row [$ key ] = $ format ? $ value ->format ($ format ) : $ value ;
503504
504505 } elseif ($ type === Type::BINARY ) {
505506 $ row [$ key ] = is_string ($ value ) ? $ this ->getResultDriver ()->unescapeBinary ($ value ) : $ value ;
You can’t perform that action at this time.
0 commit comments