// Remove the short joins
function convert_update_short_join()
{
global $files, $path;
// Now we loop through all file and do a strtr fix.
$replaces = array();
foreach ($files as $file)
{
// Get the contents of the file.
$file_contents = file_get_contents($path . '/' . $file);
// Try to find any short joins.
preg_match_all('~(\t)*FROM \(([^\)]+)\)~is', $file_contents, $matches);
// Lets loop trhough all the matches.
foreach ($matches[2] as $key => $string)
{
// Explode the short join.
$temp = explode(', ', $string);
// Start off the new string with some padding (maybe).
$newstring = $matches[1][$key] . 'FROM ' . $temp[0];
unset($temp[0]);
// Now all others we will inner join.
foreach ($temp as $str)
$newstring .= "\n" . $matches[1][$key] . ' INNER JOIN ' . $str;
// Now get it ready to go out.
$replaces[$matches[0][$key]] = $newstring;
}
}
// Now do updates to all files.
DoUpdates('strtr', $replaces);
}