@@ -25,17 +25,17 @@ public function __construct($sql) {
25
25
}
26
26
27
27
function figureOutType (){
28
- if (preg_match ('/^SELECT\s/ ' , $ this ->sql ))
28
+ if (preg_match ('/^SELECT\s/i ' , $ this ->sql ))
29
29
$ this ->type = self ::SELECT ;
30
- elseif (preg_match ('/^DELETE\s+FROM\s/ ' , $ this ->sql ))
30
+ elseif (preg_match ('/^DELETE\s+FROM\s/i ' , $ this ->sql ))
31
31
$ this ->type = self ::DELETE ;
32
- elseif (preg_match ('/^DELETE\s+ ' .self ::TABLEREF .'\s+FROM\s/ ' , $ this ->sql ))
32
+ elseif (preg_match ('/^DELETE\s+ ' .self ::TABLEREF .'\s+FROM\s/i ' , $ this ->sql ))
33
33
$ this ->type = self ::DELETEMULTI ;
34
- elseif (preg_match ('/^INSERT\s+INTO\s/ ' , $ this ->sql ))
34
+ elseif (preg_match ('/^INSERT\s+INTO\s/i ' , $ this ->sql ))
35
35
$ this ->type = self ::INSERT ;
36
- elseif (preg_match ('/^(.*)\s+UNION\s+(.*)$/ ' , $ this ->sql ))
36
+ elseif (preg_match ('/^(.*)\s+UNION\s+(.*)$/i ' , $ this ->sql ))
37
37
$ this ->type = self ::UNION ;
38
- elseif (preg_match ('/^UPDATE\s/ ' , $ this ->sql ))
38
+ elseif (preg_match ('/^UPDATE\s/i ' , $ this ->sql ))
39
39
$ this ->type = self ::UPDATE ;
40
40
else
41
41
$ this ->type = self ::UNKNOWN ;
@@ -47,11 +47,11 @@ function toSelect() {
47
47
case self ::UNION :
48
48
return $ this ->sql ;
49
49
case self ::DELETE :
50
- return preg_replace ('/^DELETE\s+FROM\s/ ' , 'SELECT 0 FROM ' , $ this ->sql );
50
+ return preg_replace ('/^DELETE\s+FROM\s/i ' , 'SELECT 0 FROM ' , $ this ->sql );
51
51
case self ::DELETEMULTI :
52
- return preg_replace ('/^DELETE\s+ ' .self ::TABLEREF .'\s+FROM\s/ ' , 'SELECT 0 FROM ' , $ this ->sql );
52
+ return preg_replace ('/^DELETE\s+ ' .self ::TABLEREF .'\s+FROM\s/i ' , 'SELECT 0 FROM ' , $ this ->sql );
53
53
case self ::UPDATE :
54
- preg_match ('/^UPDATE\s+(.*)\s+SET\s+(.*)\s+WHERE\s+(.*)$/ ' , $ this ->sql , $ subpatterns );
54
+ preg_match ('/^UPDATE\s+(.*)\s+SET\s+(.*)\s+WHERE\s+(.*)$/i ' , $ this ->sql , $ subpatterns );
55
55
return "SELECT {$ subpatterns [2 ]} FROM {$ subpatterns [1 ]} WHERE {$ subpatterns [3 ]}" ;
56
56
}
57
57
return null ;
@@ -78,7 +78,7 @@ function asExtendedExplain() {
78
78
$ sql = $ this ->asExplain ();
79
79
if (is_null ($ sql ))
80
80
return null ;
81
- $ sql = preg_replace ('/^EXPLAIN / ' , 'EXPLAIN EXTENDED ' , $ sql );
81
+ $ sql = preg_replace ('/^EXPLAIN /i ' , 'EXPLAIN EXTENDED ' , $ sql );
82
82
return $ sql ;
83
83
}
84
84
}
0 commit comments