55/**
66 * Light SQL Parser Class
77 * @author Marco Cesarato <cesarato.developer@gmail.com>
8- * @copyright Copyright (c) 2018
8+ * @copyright Copyright (c) 2020
99 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
1010 * @link https://github.com/marcocesarato/PHP-Light-SQL-Parser-Class
11- * @version 0.1.97
11+ * @version 0.1.98
1212 */
1313class LightSQLParser
1414{
@@ -23,9 +23,9 @@ class LightSQLParser
2323 */
2424 public function __construct ($ query = '' ) {
2525 $ this ->query = $ query ;
26- if (empty (self ::$ connectors_imploded ))
27- self ::$ connectors_imploded = implode ('| ' , self ::$ connectors );
28- return $ this ;
26+ if (empty (self ::$ connectors_imploded )) {
27+ self ::$ connectors_imploded = implode ('| ' , self ::$ connectors );
28+ }
2929 }
3030
3131 /**
@@ -38,12 +38,12 @@ public function setQuery($query) {
3838
3939 /**
4040 * Get SQL Query method
41- * @param $query
41+ * @param $methodQuery
4242 * @return string
4343 */
44- public function method ($ query = null ) {
44+ public function method ($ methodQuery = null ) {
4545 $ methods = array ('SELECT ' , 'INSERT ' , 'UPDATE ' , 'DELETE ' , 'RENAME ' , 'SHOW ' , 'SET ' , 'DROP ' , 'CREATE INDEX ' , 'CREATE TABLE ' , 'EXPLAIN ' , 'DESCRIBE ' , 'TRUNCATE ' , 'ALTER ' );
46- $ queries = empty ($ query ) ? $ this ->_queries () : array ($ query );
46+ $ queries = empty ($ methodQuery ) ? $ this ->_queries () : array ($ methodQuery );
4747 foreach ($ queries as $ query ) {
4848 foreach ($ methods as $ method ) {
4949 $ _method = str_replace (' ' , '[\s]+ ' , $ method );
@@ -175,6 +175,9 @@ protected function _queries() {
175175 $ queries = preg_replace ('#;(?:(?<=[" \'];)|(?=[" \']))# ' , '' , $ queries );
176176 $ queries = preg_replace ('#[\s]*UNION([\s]+ALL)?[\s]*# ' , '; ' , $ queries );
177177 $ queries = explode ('; ' , $ queries );
178+ foreach ($ queries as &$ query ) {
179+ $ query = str_replace (array ('` ' , '" ' , "' " ), '' , $ query );
180+ }
178181 return $ queries ;
179182 }
180183}
0 commit comments