I have a problem with an SQL call. I have the following tables, linked as shown...
SizeType -> hasMany Products SizeType -> hasMany Sizes Product -> hasMany StockItems Size -> hasMany StockItems When my controller attempts to fetch all the StockItems for a given product the SQL it generates doesn't quite work. Here is what it generates... SELECT `StockItem`.`id`, `StockItem`.`product_id`, `StockItem`.`size_id`, `StockItem`.`colour`, `StockItem`.`price`, `StockItem`.`count`, `Product`.`id`, `Product`.`name`, `Product`.`description`, `Product`.`size_type_id`, `Product`.`brand_id`, `Product`.`flag_id`, `Product`.`hidden`, `Product`.`created`, `Product`.`modified`, `Size`.`id`, `Size`.`size_type_id`, `Size`.`name` FROM `stock_items` AS `StockItem` LEFT JOIN `products` AS `Product` ON (`StockItem`.`product_id` = `Product`.`id`) LEFT JOIN `sizes` AS `Size` ON (`StockItem`.`size_id` = `Size`.`id` AND `Size`.`size_type_id` = 'StockItem.Product.size_type_id') WHERE `StockItem`.`product_id` = 3 LIMIT 20 ... but if I change the... `Size`.`size_type_id` = 'StockItem.Product.size_type_id' ... to ... `Size`.`size_type_id` = `Product`.`size_type_id` ... it works fine. Any ideas why this might be generating the problematic SQL statement? Thanks in advance, Toby --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
