File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -97,20 +97,28 @@ public static function analyzeByBuilder($builder)
97
97
*/
98
98
public static function analyze ($ rawSql , $ bindings )
99
99
{
100
+ $ queryData = '' ;
101
+ $ sqlOptimized = '' ;
102
+ $ errorMessage = '' ;
100
103
$ query = [
101
104
'sql ' => $ rawSql ,
102
105
'bindings ' => $ bindings ,
103
106
];
104
- $ queryData = DB ::connection ()->select ('EXPLAIN ' . $ rawSql , $ bindings );
105
107
106
- DB ::connection ()->getPdo ()->setAttribute (\PDO ::ATTR_EMULATE_PREPARES , true );
107
- $ showWarnings = DB ::connection ()->getPdo ()->query ("SHOW WARNINGS " );
108
- $ sqlOptimized = $ showWarnings ->fetchColumn (2 );
109
- DB ::connection ()->getPdo ()->setAttribute (\PDO ::ATTR_EMULATE_PREPARES , false );
108
+ try {
109
+ $ queryData = DB ::connection ()->select ('EXPLAIN ' . $ rawSql , $ bindings );
110
+ DB ::connection ()->getPdo ()->setAttribute (\PDO ::ATTR_EMULATE_PREPARES , true );
111
+ $ showWarnings = DB ::connection ()->getPdo ()->query ("SHOW WARNINGS " );
112
+ $ sqlOptimized = $ showWarnings ->fetchColumn (2 );
113
+ DB ::connection ()->getPdo ()->setAttribute (\PDO ::ATTR_EMULATE_PREPARES , false );
114
+ } catch (\Exception $ e ) {
115
+ $ errorMessage = $ e ->getMessage ();
116
+ }
110
117
111
118
return [
112
119
'queryParts ' => $ queryData ,
113
120
'query ' => $ query ,
121
+ 'error ' => $ errorMessage ,
114
122
'optimized ' => $ sqlOptimized ,
115
123
];
116
124
}
You can’t perform that action at this time.
0 commit comments