Wednesday, April 3, 2013

Re: How to perform a find with HABTM relationship?

Ok, maybe the "Post" model can lead to mistakes. Let's suppose I've a "Link" model and the content of the page that I store in the database can contain text in more than a language. I've stored the supported languages in a "Language" table. Considering that the article pointed by the link can contain more than a translation of the article (on the same page) obviously, the right relationship between Link and Language is a HABTM.

Well, I need to perform a search on the Link table starting from the language of the content: If a user searches for english contents, I wanna get just the Links that contains something in English, even if it contains the same article in more than a language.

I'm using the Paginate Component and I really tried everything... If I perform a search on the Link model specifying the Language.id field I get an "Unknown column" error, cause in the first query the Language table isnt present in the FROM statement of the query. If I use the contain behavior I dont get any error, but I see Links that are not in the specified language.

Hope this make the problem clearer. Thanks again for any reply to this topic. I really appreciate your efforts. =]

Il giorno mercoledì 3 aprile 2013 22:46:01 UTC+2, Salines ha scritto:
I do not understand, What do you want to store in languages table?


Dana srijeda, 3. travnja 2013. 15:06:49 UTC+2, korisnik Leonhart napisao je:
How can I perform a find call if I've a Model linked to another one with the Has And Belongs To Many relation? The Models involved are "Post" and "Language". According to the Cake Conventions I've created and populated the Language_Post table. I want to find only the Posts with a specific language id... Thanks in advance guys!!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: