PHP: How do I find (Oracle) parameters in a SQL query?
- by Bartb
Suppose you have a string: "SELECT * FROM TABLE WHERE column1 = :var1 AND column2 = :var2"
Now, how do I get an array with all the variables like so:
Array
(
[0] => :var1
[1] => :var2
)
I've tried it with PHP's preg_match_all, but I struggle with the regex.
$varcount = preg_match_all("/ :.+ /", $sql, $out);