@@ -1417,9 +1417,11 @@ public function truncate(): bool
14171417
14181418 $ this ->last_query = $ sql ;
14191419
1420+ $ start_at = microtime (true );
14201421 $ result = (bool ) $ this ->connection ->exec ($ sql );
1422+ $ ended_at = microtime (true );
14211423
1422- $ this ->triggerQueryEvent ($ sql , [] );
1424+ $ this ->triggerQueryEvent ($ sql , $ ended_at - $ start_at );
14231425
14241426 $ this ->last_query = $ sql ;
14251427
@@ -1523,9 +1525,11 @@ private function execute(string $sql, array $bindings = []): PDOStatement
15231525 $ this ->bind ($ statement , $ bindings );
15241526
15251527 try {
1528+ $ start_at = microtime (true );
15261529 $ statement ->execute ();
1530+ $ ended_at = microtime (true );
15271531
1528- $ this ->triggerQueryEvent ($ sql , $ bindings );
1532+ $ this ->triggerQueryEvent ($ sql , $ ended_at - $ start_at , $ bindings );
15291533 } catch (\Exception $ e ) {
15301534 throw new QueryBuilderException (
15311535 'Error executing query: ' . $ e ->getMessage () . ' | Query: ' . $ this ->last_query ,
@@ -1548,9 +1552,11 @@ public function drop(): bool
15481552
15491553 $ this ->last_query = $ sql ;
15501554
1555+ $ start_at = microtime (true );
15511556 $ result = (bool ) $ this ->connection ->exec ($ sql );
1557+ $ ended_at = microtime (true );
15521558
1553- $ this ->triggerQueryEvent ($ sql , [] );
1559+ $ this ->triggerQueryEvent ($ sql , $ ended_at - $ start_at );
15541560
15551561 return $ result ;
15561562 }
@@ -1668,12 +1674,13 @@ public function setWhereDataBinding(array $data_binding): void
16681674 * Trigger the query event
16691675 *
16701676 * @param string $sql
1677+ * @param float $execution_time
16711678 * @param array $bindings
16721679 * @return void
16731680 */
1674- private function triggerQueryEvent (string $ sql , array $ bindings ): void
1681+ private function triggerQueryEvent (string $ sql , float $ execution_time = 0 , array $ bindings = [] ): void
16751682 {
1676- Database::triggerQueryEvent ($ sql , $ bindings );
1683+ Database::triggerQueryEvent ($ sql , $ execution_time , $ bindings );
16771684 }
16781685
16791686 /**
0 commit comments