Sunday, August 31, 2014

Re: find all on complex model

You haven't provided any code other than a straight forward find query, we're likely to point you to book when this is the case, we need your code to help you also (like when I asked to see your associations).

Here's an example based on the models and desired relationships you mentioned, this works for me but it assumes you've named your tables correctly like such:

lessons
id | tutor_id | ...
lesson_students
id | lesson_id | student_id
tutors
id | ...
students
id | ...


It's much more simple to use contain over joins and hopefully you can see why.

Also notice the 'with' part on the HABTM joins, writing this tells the association which model to use to join the tables, you can leave this blank and it will create a model on the fly. See more in the HABTM docs on this.

Specifying one in advance this way allows you to access the join model easily and write methods within it, it's not required.


On 31 August 2014 01:05, ajt <jagguy999@gmail.com> wrote:
No this is not what you do as the Student has a HABTM relationship and I am told to do joins.

Also when saying adding something I NEED the code as please dont  assume by adding containable I know what your talking about or the docs explain things.

I dont understand why simply getting information from 4 tables is just so complicated and where is the complete examples of this?





--
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.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards
 Stephen Speakman

--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: