Jump to:

3459 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » lowercase table hack

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

Page: 1
Go to End
Author Topic: 2275 Views
  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    lowercase table hack Link to this post

    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).'` ;');
    }

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: lowercase table hack Link to this post

    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

  • brandstudionz
    Avatar
    Community Member
    3 Posts

    Re: lowercase table hack Link to this post

    Legend this was really annoying the hell out of me!

    2275 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.