So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.")
$t_columns = array('id', 'name', 'label');
$r_columns = array('related_value');
INPUT:
id > 1 AND (name = 'Hello' OR label IN ('World', 'Planet name AND label')) AND (related_value > 1 AND related_value < 50)
OUTPUT:
t.id > 1 AND (t.name = 'Hello' OR t.label IN ('World', 'Planet name AND label')) AND (r.related_value > 1 AND r.related_value < 50)
Notice how you can't do a normal str_replace. What would be the simplest code (I'm guessing preg_replace) to ensure that all table names are properly prepended?