I use cakephp and want to display all Views that fall into the category "X". I have 4 tables with a HABTM relationship.
Users → (hasMany) → Views ↔ (hasAndBelongsToMany) ↔ Categories
but I would like to do this using $ this-> paginate (), and for each view I would like to display the user who posted the message.
User table
Id | Name
-----+-------------------
1 | User 1
2 | User 2
Submission table
Id | Name | User_id
-----+-------------------+--------------
1 | Submission 1 | 1
2 | Submission 2 | 2
Category table
Id | Name
-----+-------------------
1 | Category 1
2 | Category 2
Subcategory Table
Id | Submission_id | Category_id
-----+-------------------+-------------------
1 | 1 | 1
2 | 1 | 2
3 | 2 | 1
I am really having trouble creating a paginate that can do this, I am starting to think that this is not possible if I do not miss something.
If I have not used cakephp, this is the request I would like to make
SELECT
*
FROM
submissions_categories,
submissions,
users
WHERE
submissions_categories.category_id = 8
AND
submissions_categories.submission_id = submissions.id
AND
submissions.user_id = users.id