Return to Snippet

Revision: 32810
at October 2, 2010 10:29 by roblynch


Initial Code
$dbname = 'database_name';
preg_match("/Table '".$dbName."\.(.*)' doesn't exist/",$matches[2],$tables);
if(isset($tables[1]) && $tables[1] == true)
{
	$sql = 'RENAME TABLE '.strtolower($tables[1]).' TO '.$tables[1].';';
	mysql_query($sql);
	echo "<script type=\"text/javascript\" language=\"JavaScript\">window.location.reload();</script>";
}

Initial URL

                                

Initial Description
This code should be inserted into /sapphire/core/model/MySQLDatabase.php at line 399 (after the if statment ends and before the user_error call)

Be sure to replace 'database_name' with, well you know...

When I used this I first loaded the home page.  This fixed a large number of the tables, then ran /dev/build and that fixed the rest.

Initial Title
Automatically fix lower case table names in SilverStripe

Initial Tags

                                

Initial Language
PHP