Re: hasAndBelongsToMany does not work
Provide the models code
-- On Fri, Oct 7, 2011 at 11:26 PM, khalili merouane <merouane.khalili@gmail.com> wrote:
Hello,
I have two tables categories and products when I try to view a
category, I just have the information in the category without
products.
When I check the applications running I see that selects the products
but does not display
I have the join table categories_products
and that the table queries
(default) 6 queries took 14 ms
Nr Query Error Affected Num. rows Took (ms)
1 SHOW FULL COLUMNS FROM `products` 19 19 6
2 SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE
COLLATION_NAME= 'utf8_general_ci'; 1 1 1
3 SHOW FULL COLUMNS FROM `categories` 9 9 3
4 SHOW FULL COLUMNS FROM `categories_products` 5 5 2
5 SELECT `Product`.`id`, `Product`.`name`, `Product`.`slug`,
`Product`.`small_price`, `Product`.`medium_price`,
`Product`.`large_price`, `Product`.`discount_percentage`,
`Product`.`small_image_url`, `Product`.`large_image_url`,
`Product`.`description`, `Product`.`extended_description`,
`Product`.`additional_description`, `Product`.`active_for_home_page`,
`Product`.`position_home_page`, `Product`.`active_small_price`,
`Product`.`active_medium_price`, `Product`.`active_large_price`,
`Product`.`active`, `Product`.`gift_id` FROM `products` AS `Product`
WHERE `Product`.`id` = 20 LIMIT 1 1 1 1
6 SELECT `Category`.`id`, `Category`.`name`, `Category`.`slug`,
`Category`.`description`, `Category`.`description_is_image`,
`Category`.`image_url`, `Category`.`type`, `Category`.`popularity`,
`Category`.`active`, `AppModel`.`id`, `AppModel`.`category_id`,
`AppModel`.`product_id`, `AppModel`.`position`,
`AppModel`.`popularity` FROM `categories` AS `Category` JOIN
`categories_products` AS `AppModel` ON (`AppModel`.`product_id` = 20
AND `AppModel`.`category_id` = `Category`.`id`) 1 1 1
I test the last mysql query, it m'affiche the necessary information.
But on the controller, it just gives me information on the category.
I even do $ this-> Category-> recursive = 2;
Thank you in advance
--
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
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home