我从表中查询所有行,并获得所有语言的所有行...
例如: GalleryCategoriesController.php
<?php
class GalleryCategoriesController extends AppController
{
function index()
{
$galleryCategories = $this->GalleryCategory->find('all');
print_r($galleryCategories);
$this->set('galleryCategories', $galleryCategories);
}
}
?>
GalleryCategory.php(模型)
<?php
class GalleryCategory extends AppModel
{
public $tablePrefix = 'ef_';
var $name = 'GalleryCategory';
public $actsAs = array('Translate' => array(
'title' => 'titleTranslation',
'title_sub' => 'titleSubTranslation',
'description' => 'descriptionTranslation'
)
);
}
?>
结果:
Array
(
[0] => Array
(
[GalleryCategory] => Array
(
[id] => 1
[gallery_category_id] => 0
[title] => Test title
[title_sub] => Test subtitle
[description] => Test description
[status] => 2
[locale] => hun
)
[titleTranslation] => Array
(
[0] => Array
(
[id] => 65
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => title
[content] => Test title hungarian
)
[1] => Array
(
[id] => 80
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => title
[content] => Test title english
)
)
[titleSubTranslation] => Array
(
[0] => Array
(
[id] => 66
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => title_sub
[content] => Test subtitle hungarian
)
[1] => Array
(
[id] => 81
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => title_sub
[content] => Test subtitle english
)
)
[descriptionTranslation] => Array
(
[0] => Array
(
[id] => 67
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => description
[content] => Test description hungarian
)
[1] => Array
(
[id] => 82
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => description
[content] => Test description english
)
)
)
)
我怎么能只得到匈牙利语翻译?因为如果我在网站上有六种语言,并且我查询任何内容,我会得到六种语言的......这太可怕了......