Something interesting to think about
:
PHP Code:
$dbprefix = 'newdb';
$string = "SELECT * FROM user AS user WHERE userid='moo'";
$pattern = '/(.*)FROM[\s\n\r]+([A-Za-z]+)[\s\n\r]+AS[\s\n\r]+(\\2)(.*)/';
if(preg_match($pattern, $string, $array))
{
print_r($array);
$nstring = preg_replace($pattern, "$1 FROM $dbprefix.$2 AS $3 $4", $string);
echo '<br />' . $nstring;
}
Now thinking about it, if we did the same for INSERT, UPDATE, REPLACE INTO and DELETE we could be on to something as it seems the devs have introduced aliases to all tables since the first gold release