Hi,

I am trying out CakePHP on an existing (and messy) website to see if
it is going to be beneficial to use it for the new features from now
on. I have been creating a test model that allows admin to search
through users based on various fields (userId, name, email address,
orderId).

I have 3 tables that are being used for this:
Users
Customers
Orders

Users links to Customers on a 1 to 1 relationship on 'userId',
Customers links to Orders on a 1 to many relationship on 'customerId'.

The search feature is working correctly, except that I can't figure
out how to set conditions on the Orders table.
This is the query I would write normally to get the user who placed a
certain order:

SELECT * FROM users u
LEFT JOIN customers c ON u.userId = c.userId
LEFT JOIN orders o ON o.customerId = c.customerId
WHERE o.orderId = $orderId.

I have set up models for Users, Customers and Orders, With 'Users
$hasOne ' referencing Customers, and 'Customers $hasMany' referencing
Orders.

If the conditions only reference the Users table, the script brings
out the Orders data correctly, but I can't get it to allow me to
search for an orderId, as Orders is referenced by Users through
Customers.

Any help on this would be great, I can upload code if necessary.

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