Thanks a lot for your reply John.
I'll try with that example you linked me. I think that would do the
trick.

I really appreciate your reply John. Regards

On 18 jun, 02:26, John Andersen <j.andersen...@gmail.com> wrote:
> Take a look at using the same solution as in the FilterTag example in
> the CakePHP book, 
> see:http://book.cakephp.org/view/1039/Associations-Linking-Models-Togethe...
>
> The last example is the one. Maybe it can be applied to your issue :)
> Enjoy,
>    John
>
> On Jun 18, 6:40 am, Roland Pish <rolandp...@gmail.com> wrote:
>
> > Hi!
> > I've been struggling with something that I cannot seem to get working.
>
> > I have this relationship: Treatment HABTM Symptom
>
> > What I want to do is: search treatments by symptom, and the result
> > must display treatments fields (id, name, cost, etc).
>
> > For now, I've been doing this in treatments_controller.php:
>
> > $symptoms = 
> > $this->Treatment->Symptom->find('all',array('conditions'=>array('Symptom.name
> >  LIKE'=>"%$search
>
> > %"))); // $search is the search value that can be a part of a word
> > (i.e. "ache").
>
> > The first problem is that I cannot "order" that find by Treatment.name
> > because it shows the error: unknown field Treatment.name. How can I
> > overcome this? How can I include fields of the "original" model table
> > in this find?
>
> > The other problem is that after executing the above, I have to walk
> > into array $symptoms searching (for each symptom) for the sub-array
> > $Treatment to get treatments for the current symptom, because that
> > "find" gives me an array of symptoms (and not treatments). This is
> > kind of uncomfortable because more than one found symptom can have the
> > same treatment, so I have to take care of the duplicate treatments
> > manually.
> > Is there some way to tell "find" to get treatments rather than
> > symptoms and include the field Symptom.name in the conditions array?
>
> > I really appreciate your help.
>
> > Regards.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to