我有四张桌子:
gallery_categories 表: id (int); 标题(varchar);
画廊图片表: id(int);标题(varchar);
gallery_categories_gallery_pictures 表联合上表: gallery_category_id (int); Gallery_picture_id (int);
和 i18n 表: id (int) locale (varchar) model (varchar) foreign_key (int) field (varchar) content (text)
我试过了:
$this->GalleryCategory->bindModel(array(
'hasOne' => array(
'GalleryCategoriesGalleryPicture',
'GalleryPicture' => array(
'className' => 'GalleryPicture',
'foreignKey' => false,
'conditions' => array('GalleryPicture.id = GalleryCategoriesGalleryPicture.gallery_picture_id')
))));
$galleryCategories = $this->GalleryCategory->find('all', array(
'fields' => array('GalleryCategory.*','GalleryPicture.*')
));
但它始终返回正确的类别表字段和错误的图片表字段......类别字段包含正确的翻译单词。Pictrures 字段包含错误的翻译字词。
模型:
class GalleryCategory extends AppModel
{
public $tablePrefix = 'ef_';
var $name = 'GalleryCategory';
public $actsAs = array('Translate' => array(
'title' => 'titleTranslation'
)
);
}
class GalleryPicture extends AppModel
{
public $tablePrefix = 'ef_';
var $name = 'GalleryPicture';
public $actsAs = array('Translate' => array(
'title' => 'titleTranslation'
)
);
}
我怎样才能从两个表中得到正确的翻译词?
ps:“i18n 数据库表”的翻译仅适用于一个表(exp:仅 GalleryCategory 或仅 GalleryPicture)。