Tuesday, April 26, 2011

read(null,$id) or findById($id) and limit data in associated model

Hello.
I Have two models,Brands and Products, where Brand hasmany Products

When I calling action 'view' in my products controller, I need
following result , .

SELECT `Brand`.`id`, `Brand`.`active`, `Brand`.`name`,
`Brand`.`description`, `Brand`.`image`, `Brand`.`website`,
`Brand`.`created`, `Brand`.`modified` FROM `brands` AS `Brand` WHERE
`Brand`.`id` = 10 LIMIT 1

SELECT `Product`.`id`, `Product`.`active`, `Product`.`brand_id`,
`Product`.`name`, `Product`.`created`, `Product`.`modified` FROM
`products` AS `Product` WHERE active = 1 AND `Product`.`brand_id` =
(10) ORDER BY `created` DESC LIMIT 9

How can do with read() or findById() ???

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: