question about localization and CDbMessageSource

read article http://www.yiiframework.com/doc/api/1.1/CDbMessageSource

table SourceMessage, field message. so first yii finds record by message and maybe by field category. but why message is not indexed field? if in table will be many records, also type TEXT not good

I know that isn’t precisely that topic, but I can’t create new threads in forum yet…

There’s also a MySQL issue

[sql]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

);[/sql]

This is code from documentation (the same link kusanagi posted). When I paste it to phpMyAdmin it throws


# MySQL returned an empty result set (i.e. zero rows)

below both tables. Moreover, foreign key is not created. And therefeore Yii issue: Gii does not generate relations in models. Any idea why?

it’s just a variant of implementation and you can add an index to message field if you need (and if you are using storage engine which supports fulltext indexes e.g. MyISAM)

and I think that it will be OK to change type to CHAR/VARCHAR for perfomance reason, but in this case you will not be able to store messages longer than 255 characters

christopher, it seems like you are using MyISAM which doesn’t support foreign keys, try




CREATE TABLE SourceMessage

(

    id INTEGER PRIMARY KEY,

    category VARCHAR(32),

    message TEXT

) ENGINE = InnoDB;


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

) ENGINE = InnoDB;



@ololo, thanks! this is it :)