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