[Solved] To change CDbMessageSource table's field name and type.

Hi, Guys

This is about internationalization.

According to CDbMessageSource

We have this table structure.




CREATE TABLE SourceMessage

(

    id INTEGER PRIMARY KEY,

    category VARCHAR(32),

    message TEXT

);

CREATE TABLE Message

(

    id INTEGER,

    language VARCHAR(16),

    translation TEXT,

    PRIMARY KEY (id, language),

    CONSTRAINT FK_Message_SourceMessage FOREIGN KEY (id)

         REFERENCES SourceMessage (id) ON DELETE CASCADE ON UPDATE RESTRICT

);



From what I’ve read we can do only change the table name via property


sourceMessageTable

and


translatedMessageTable

.

So what I want to ask are.

1. Can we change the field name of each table?

For example : I want to change the SourceMessage’s id into SourceMessage’s label_id because I need to integrate this table into my database as it has its own convention.

[b]

  1. Can we change the field type if each table?[/b]

For example : I want to change the Message’s language into Message’s language_id because I need to use another table to keep the language data.

3. If it possible, please guide me how.

Thanks in advance :lol:

It would be perfect if Yii can do it ;D

Alright I finally found some answers.

I did the core hack in CDbMessageSource all query go there so I did changing it to match my need.

If anyone has a better idea, please let me know :lol:

You can’t change column names but you can extend CDbMessageSource class and use it instead of the original one. Actually, you just have to change sql query in the loadMessaged() function.

Oh great! thanks

That works for me :lol: