#5943: Error getting Translation data using translation behaviour.
---------------------------------------+------------------------------------
Reporter: [email protected] | Type: Bug
Status: new | Priority: High
Milestone: 1.2.x.x | Component: Behaviors
Version: 1.2 Final | Severity: Major
Keywords: Translation, Behaviors | Php_version: PHP 5
Cake_version: 1.2.0.7962 |
---------------------------------------+------------------------------------
I'm using translation behaviour to mantain data for an entity called Post.
Post has 3 main fields name, title, body. Name has no translations, while
title and body are translated fields. So I write in the Model code:
{{{
var $actsAs = array('Translate'=>array('title','body'));
}}}
When I save data in on language (lets say spanish "spa") everything works
fine. When I read data from this same Post in "en_us" I don't get any
data.
{{{
$this->Post->locale = "en_us";
$this->data = $this->Post->read(null, $id);
}}}
where $id is the Post.id for the record previously saved in spanish.
When I activate degug I see that the query to get data is:
{{{
SELECT `Post`.*, `Owg`.*, `Menuitem`.*, `I18n__title`.`content`,
`I18n__body`.`content` FROM `posts` AS `Post` LEFT JOIN `i18n` AS
`I18n__title` ON (`Post`.`id` = `I18n__title`.`foreign_key` AND
`I18n__title`.`model` = 'Post' AND `I18n__title`.`field` = 'title') LEFT
JOIN `i18n` AS `I18n__body` ON (`Post`.`id` = `I18n__body`.`foreign_key`
AND `I18n__body`.`model` = 'Post' AND `I18n__body`.`field` = 'body') LEFT
JOIN `owgs` AS `Owg` ON (`Post`.`owg_id` = `Owg`.`id`) LEFT JOIN
`menuitems` AS `Menuitem` ON (`Post`.`menuitem_id` = `Menuitem`.`id`)
WHERE `Post`.`id` = 1 AND `I18n__title`.`locale` = 'en_us' AND
`I18n__body`.`locale` = 'en_us' LIMIT 1
}}}
this query doesn't return any record. But it must return almost the
Post.id field, and in my case also Post.name.
if I change the query for this:
{{{
SELECT `Post` . * , `Owg` . * , `Menuitem` . * , `I18n__title`.`content` ,
`I18n__body`.`content`
FROM `posts` AS `Post`
LEFT JOIN `i18n` AS `I18n__title` ON ( `Post`.`id` =
`I18n__title`.`foreign_key`
AND `I18n__title`.`model` = 'Post'
AND `I18n__title`.`field` = 'title'
AND `I18n__title`.`locale` = 'en_us' )
LEFT JOIN `i18n` AS `I18n__body` ON ( `Post`.`id` =
`I18n__body`.`foreign_key`
AND `I18n__body`.`model` = 'Post'
AND `I18n__body`.`field` = 'body'
AND `I18n__body`.`locale` = 'en_us' )
LEFT JOIN `owgs` AS `Owg` ON ( `Post`.`owg_id` = `Owg`.`id` )
LEFT JOIN `menuitems` AS `Menuitem` ON ( `Post`.`menuitem_id` =
`Menuitem`.`id` )
WHERE `Post`.`id` =1
}}}
moving the filter for I18n_title.locale = 'en_us' and I18n_body.locale =
'en_us" inside the left join conditions.
I get the expected data, so maybe the query construction is not correct.
--
Ticket URL: <https://trac.cakephp.org/ticket/5943>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---