i have spent searching and finding a solution for my problem the entire day and couldn't find anything for my Problem. I have a query which needs to be "exploded" via regular expression. I want to get the selected fields, the table and the fields after the where condition (without the check itself).
SELECT `a`, `b`, `c` FROM `d` WHERE `e` > 1 OR `d` > 1
My attempt looks like the following:
/SELECT (?<selectedFields>(,*?)\`(.*?)\`) FROM (?<tableName>\`(.*?)\`) WHERE (?<checkFields>\`(.*?)\`)/
The Problem I have is that the regular expression stops after the first field at the where condition. The Output i got looks like the following.
Array
(
[0] => Array
(
[0] => SELECT `a`, `b`, `c` FROM `d` WHERE `e`
)
[selectedFields] => Array
(
[0] => `a`, `b`, `c`
)
[1] => Array
(
[0] => `a`, `b`, `c`
)
[2] => Array
(
[0] =>
)
[3] => Array
(
[0] => a`, `b`, `c
)
[tableName] => Array
(
[0] => `d`
)
[4] => Array
(
[0] => `d`
)
[5] => Array
(
[0] => d
)
[checkFields] => Array
(
[0] => `e`
)
[6] => Array
(
[0] => `e`
)
[7] => Array
(
[0] => e
)
)
I need the "checkFields" in the same kind of array i got the selected fields. What am i doing wrong? Second thing is that the selectFields from the regular expression are not as expected an array with each fieldname, it is separated by ','...