There are three tables, Colors, Products and ProductStyles. The logical relation is Products HAS_MANY ProductStyles and Products also HAS_MANY Colors. I need to find the image path which stores in ProductStyles base on the Inventory which stories is Colors.
the SQL statement should be
SELECT DISTINCT p.ProductID, p.FilePath
FROM Colors as c, Product_Styles as p
WHERE c.TryAtHome_Inventory > 0
AND c.ProductID = p.ProductID
However, If I use CDbCriteria or other method instead of complete SQL statement, how I can do that? Also, the findBySql returns base on the select attribute in the statement or base on a model? What it will return if I use model()->findBySql(‘upper SQL statement’)?