私はモデルを持っています:
class Product extends AppModel {
var $actsAs=array(
'Translate' => array(
'title', 'excerpt', 'overview', 'construction', 'options', 'features', 'benefits'
)
);
}
私のコントローラーでは、次のようにクエリしています。
$this->Product->findPublic('all');
デフォルトの動作は、クエリ内の翻訳された各フィールドのエイリアスを独自のテーブルとして追加することです。次に例を示します。
SELECT `Product`.*, `I18n__title`.`content`, `I18n__excerpt`.`content`, `I18n__overview`.`content`, `I18n__construction`.`content`, `I18n__options`.`content`, `I18n__features`.`content`, `I18n__benefits`.`content` FROM `ck_products` AS `Product` LEFT JOIN `ck_i18n` AS `I18n__title` ON (`Product`.`id` = `I18n__title`.`foreign_key` AND `I18n__title`.`model` = 'Product' AND `I18n__title`.`field` = 'title') LEFT JOIN `ck_i18n` AS `I18n__excerpt` ON (`Product`.`id` = `I18n__excerpt`.`foreign_key` AND `I18n__excerpt`.`model` = 'Product' AND `I18n__excerpt`.`field` = 'excerpt') LEFT JOIN `ck_i18n` AS `I18n__overview` ON (`Product`.`id` = `I18n__overview`.`foreign_key` AND `I18n__overview`.`model` = 'Product' AND `I18n__overview`.`field` = 'overview') LEFT JOIN `ck_i18n` AS `I18n__construction` ON (`Product`.`id` = `I18n__construction`.`foreign_key` AND `I18n__construction`.`model` = 'Product' AND `I18n__construction`.`field` = 'construction') LEFT JOIN `ck_i18n` AS `I18n__options` ON (`Product`.`id` = `I18n__options`.`foreign_key` AND `I18n__options`.`model` = 'Product' AND `I18n__options`.`field` = 'options') LEFT JOIN `ck_i18n` AS `I18n__features` ON (`Product`.`id` = `I18n__features`.`foreign_key` AND `I18n__features`.`model` = 'Product' AND `I18n__features`.`field` = 'features') LEFT JOIN `ck_i18n` AS `I18n__benefits` ON (`Product`.`id` = `I18n__benefits`.`foreign_key` AND `I18n__benefits`.`model` = 'Product' AND `I18n__benefits`.`field` = 'benefits') WHERE `Product`.`status` = 'active' AND NOT (`Product`.`slug` = '') AND `I18n__title`.`locale` = 'eng' AND `I18n__excerpt`.`locale` = 'eng' AND `I18n__overview`.`locale` = 'eng' AND `I18n__construction`.`locale` = 'eng' AND `I18n__options`.`locale` = 'eng' AND `I18n__features`.`locale` = 'eng' AND `I18n__benefits`.`locale` = 'eng'
追加するフィールドが多いほど、クエリが遅くなります。実際、今はタイムアウトしています。Cakeでこれを行うより良い方法はありますか?