Hi there,

that's for the cakephp professionals among you, which hopefully you all are. ;-)

I have three tables:

agents (keeps information of the call-center agents using the application)
branches (keeps information on the branches the agent works for, which
may be several or just one)
agents_branches (for joining the two together)

In the model, the HABTM relationship is defined accordingly.

To get a list of agents that are not assigned to any branch, I need
the following code:

SELECT * FROM `agents` LEFT JOIN agents_branches ON
agents_branches.agent_id = agents.id WHERE agents_branches.agent_id IS
NULL

When I do $this->Branch->query($myQuery), this works fine.

However, I want to do it "the cake way" and not use the direct query,
if possible. However, I don't know how. A normal find will give me all
agents and all branches. When I set a condition, cakephp doesn't use
agents_branches anymore, and puts out an error, because it cannot find
a column agents_branches.agent_id. Can anyone help me?

All the best,
Heidi.

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 [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

Reply via email to