I’ve been building an intranet for visicswire. This intranet is going to be the backbone of our new communication on projects. We’ll be able to see where a project was, where it is, and where it’s going. With the relations of different pieces of data within the projects and the intranet itself, I was having trouble doing the proper searches and implementing the proper security.
I had a model, Projects. That projects model hasAndBelongsToMany users (all the users that can be working on that project or many other projects). That relationship uses a join table in the middle that matches a user’s id number up with a project’s id number. Well, unfortunately, if I want to know what projects a user with a particular id is attached to, I cannot get the answer using cakePHP.
CakePHP is not yet smart enough in it’s SQL query building to know that I might want to limit a result set based on a related model and not the model I am querying. Thus, it makes it a bit hard to do queries automagically that have multiple limiters in separate models.
I was able though, to finally find someone who mentioned how to get around this. Thanks to Mr. Dawson, I created a model for my join table and now I can use it to do a seemingly complex query.
Sphere: Related Content