Skip to content

Commit 5850cb7

Browse files
committed
\Sage::showEloquentQueries() -- first of many various debug helpers in Sage class
1 parent 84a989d commit 5850cb7

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Sage.php

+9
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,15 @@ public static function doDump($data = null)
696696
return 5463;
697697
}
698698

699+
public static function showEloquentQueries()
700+
{
701+
// maintain PHP5.1+ compatibility
702+
if (SageHelper::php53orLater()) {
703+
self::$aliases[] = __CLASS__ . '::' . __FUNCTION__;
704+
705+
require SAGE_DIR . 'inc/eloquentListener.inc.php';
706+
}
707+
}
699708

700709
/*
701710
* ██████╗ ██████╗ ██╗██╗ ██╗ █████╗ ████████╗███████╗

inc/eloquentListener.inc.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$queryNumber = 0;
4+
\DB::listen(function ($query) use (&$queryNumber) {
5+
// todo ideally we should detect where Sage::showEloquentQueries() was invoked from and display that.
6+
$state = Sage::saveState();
7+
Sage::$displayCalledFrom = false;
8+
9+
$EloquentQuery = array('#' => $queryNumber++, 'sql' => $query->sql, 'bindings' => $query->bindings);
10+
Sage::dump($EloquentQuery);
11+
12+
Sage::saveState($state);
13+
});

sage.phar

782 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)