Hi Leonhart, And if you look from another perspective.. Try to perform a search on the Language model, filtering by laguage_name field and then CakePHP will take care of getting the HABTM results from your Post model.
What do you think? On Wednesday, April 3, 2013 6:03:09 PM UTC-3, Leonhart wrote: > > 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? >> >> Look here: >> http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html >> >> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
