I was kinda hoping there was some clever way to do this. Besides how would i go about doing this in eg. Commands I don't think the command object has access to the project object as they are not directly linked.
On 22 Dec., 16:19, Smelly_Eddie <[email protected]> wrote: > I think you may want to check out the 'finder query' and adjust it > for each of your test and command models. > > On Dec 21, 5:05 pm, Ralle <[email protected]> wrote: > > > I think CakePHP has a really clever way to do this, so instead of > > reinventing the wheel, i'd ask you guys. I've used the search feature > > and read through the api. > > I have the folowing models > > > Project > > Suite belongsTo Project > > Test belongsTo Suite > > Command belongsTo Test > > > At the login screen of the app you chose the project and the > > project_id is stored in the session variable. > > After that i want all models that in any way has a relation the > > Project to only return data from that project. > > Say i wanted to list all Tests, it should add something like this to > > the sql "WHERE test.suite_id = suite.id AND suite.project_id=34" > > For commands this would be "WHERE commands.test_id = test.id AND > > tests.suite_id = suite.id AND suites.project_id=34" > > > I tried adding a beforeFind function to the project model > > function beforeFind($queryData){ > > $queryData['conditions']['project_id'] = $_SESSION['project_id']; > > return $queryData;} > > > Didn't work as the function wasn't being called when another model > > called the project object, eg. Command or Test > > > Cheers, Ralle --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
