@@ -93,8 +93,12 @@ public function __construct(
9393 string $ schema = null ,
9494 string $ host = 'localhost ' ,
9595 int $ port = 3306 ,
96- Logger $ logger = null
96+ Logger $ logger = null ,
97+ DatabaseCollector $ collector = null
9798 ) {
99+ if ($ collector ) {
100+ $ this ->setDebugCollector ($ collector );
101+ }
98102 $ this ->logger = $ logger ;
99103 $ this ->connect ($ username , $ password , $ schema , $ host , $ port );
100104 }
@@ -260,13 +264,21 @@ protected function setCollations(string $charset, string $collation) : bool
260264 $ this ->mysqli ->set_charset ($ charset );
261265 $ charset = $ this ->quote ($ charset );
262266 $ collation = $ this ->quote ($ collation );
263- return $ this ->mysqli ->real_query ("SET NAMES {$ charset } COLLATE {$ collation }" );
267+ $ statement = "SET NAMES {$ charset } COLLATE {$ collation }" ;
268+ $ this ->lastQuery = $ statement ;
269+ return isset ($ this ->debugCollector )
270+ ? $ this ->addToDebug (fn () => $ this ->mysqli ->real_query ($ statement ))
271+ : $ this ->mysqli ->real_query ($ statement );
264272 }
265273
266274 protected function setTimezone (string $ timezone ) : bool
267275 {
268276 $ timezone = $ this ->quote ($ timezone );
269- return $ this ->mysqli ->real_query ("SET time_zone = {$ timezone }" );
277+ $ statement = "SET time_zone = {$ timezone }" ;
278+ $ this ->lastQuery = $ statement ;
279+ return isset ($ this ->debugCollector )
280+ ? $ this ->addToDebug (fn () => $ this ->mysqli ->real_query ($ statement ))
281+ : $ this ->mysqli ->real_query ($ statement );
270282 }
271283
272284 /**
0 commit comments