Re: trouble with self association
On Sat, Dec 4, 2010 at 11:52 AM, John Andersen <j.andersen.lv@gmail.com> wrote:
> The way I would solve this issue, is to have not one model and include
> all the associations within that one, but to have two models, one for
> the Book and one for the TranslatedBook. Thus you can avoid the
> belongsTo itself association inside the Book model, which can give
> confusing results, as you have seen.
>
> Both models will still refer to the same table though.
I considered that, also. But I need to list all books together,
regardless of whether they're translations, have translations, or
neither. I think using separate classes would make things more
complicated. For now, I've gotten around the problem by doing:
if (!empty($data['TranslationSource']) &&
!empty($data['TranslationSource']['id']))
That's not ideal but it works.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home