Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

lowercase table hack


Go to End


3 Posts   2840 Views

Avatar
Nicolaas

Forum Moderator, 224 Posts

24 August 2009 at 3:52pm

Edited: 24/08/2009 3:53pm

I recently ended up with a database in which all tables where lowercase.

I used the following rather dirty hack to fix this:

put the following code in line ~ 189 of sapphire/core/model/DatabaseAdmin.php

$t = $dataClass;
if(DB::query('SELECT * FROM information_schema.tables WHERE table_schema like binary "'.strtolower($t).'" or Table_Name like binary "'.strtolower($t).'";')->value()) {
  DB::query('RENAME TABLE `'.strtolower($t).'` TO `'.($t).'` ;');
}

put the following code in around line 275 of sapphire/core/model/MySQLDatabase.php...

public function fieldList($table) { 
 $t = $table;
 if(DB::query('SELECT * FROM information_schema.tables WHERE table_schema like binary "'.strtolower($t).'" or Table_Name like binary "'.strtolower($t).'";')->value()) {
   DB::query('RENAME TABLE `'.strtolower($t).'` TO `'.($t).'` ;');
 }

Avatar
brokemeister

Community Member, 30 Posts

12 September 2009 at 12:15am

Hi!

I'm pretty sure you build your database on a wamp installation.

You have to configure your database:

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

Cheers,

Malte

Avatar
brandstudionz

Community Member, 3 Posts

9 December 2009 at 5:58pm

Legend this was really annoying the hell out of me!