I have a model Company, and I would like to view a list of related contacts. The relationship is as shown in the figure attached: 2497
The SQL to do this would look like this:
SELECT p.*
FROM Person AS p
LEFT OUTER JOIN ContactPerson AS cp
LEFT OUTER JOIN CompanyContact AS cc
ON cc.contactId = cp.id
ON cp.personId = p.id
WHERE cc.companyId = 1
The question is how do I do this using CDbCriteria?
Can you tell what line of code you wrote to render your view? My problem is if i render a view and pass one particular model, called view doesn’t recognise fields from other models other than its own.
in your case how will you display the fields from ContactPerson and CompanyContact when rendering Person view?