#5593: Translate behavior, find('all') and recursive = -1
-------------------------------------+--------------------------------------
Reporter: kakaja | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Behaviors
Version: RC3 | Severity: Normal
Keywords: translate, recursive | Php_version: PHP 5
Cake_version: |
-------------------------------------+--------------------------------------
= What I did =
User belongs to Group and Style[[BR]]
User acts as 'Translate'[[BR]]
[[BR]]
'''$this->User->find('all',array('recursive'=>-1));'''[[BR]][[BR]]
= What I expect =
a result with information only with User data (with translated fields)
without any data of Group or Style[[BR]][[BR]]
= Why it didn't meet my expectations =
this query ALWAYS gives this error:[[BR]]
[[BR]]
'''SQL Error: 1051: Unknown table 'Group''''[[BR]]
[[BR]]
because the query created by cake is the following:[[BR]]
[[BR]]
'''SELECT `User`.*, `Group`.*, `Style`.*, `I18n__description`.`content`
FROM `users` AS `User` LEFT JOIN `i18n` AS `I18n__description` ON
(`User`.`id` = `I18n__description`.`foreign_key` AND
`I18n__description`.`model` = 'User' AND `I18n__description`.`field` =
'description') WHERE `I18n__description`.`locale` = 'fre' ORDER BY
`User`.`place` ASC'''[[BR]]
[[BR]]
if I detach Translate behavior [[BR]]
[[BR]]
'''$this->User->Behaviors->detach('Translate');'''[[BR]]
[[BR]]
the query is ok:[[BR]]
[[BR]]
'''SELECT `User`.`id`, `User`.`active`, `User`.`ref`, `User`.`place`,
`User`.`title`, `User`.`group_id`, `User`.`style_id`, `User`.`picture`,
`User`.`created`, `User`.`modified` FROM `Users` AS `User` WHERE 1 = 1
ORDER BY `User`.`place` ASC'''[[BR]]
[[BR]]
Any attempt of getting just User data doesn't work as there are always
"`Group`.*, `Style`.*" added automatically in the query:[[BR]]
[[BR]]
$this->User->recursive=-1;[[BR]]
$this->User->contain=false;[[BR]]
$this-User->find('all', array('recursive'=>-1));[[BR]]
$this-User->find('all', array('contain'=>false));[[BR]]
[[BR]]
if I put 'fields' in options there is no error because no Group or Style
added in the query.[[BR]]
[[BR]]
cake version: 1.2.0.7692 RC3
--
Ticket URL: <https://trac.cakephp.org/ticket/5593>
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
-~----------~----~----~----~------~----~------~--~---