나는 모델 이름과 이미지가 두 가지있다. 여기 관계는 이미지와 같이 많은 의견이 있습니다. 이제 내 목록 페이지에서 모든 이미지 세부 정보와 해당 이미지에 대한 의견 만 표시하고 싶습니다. 내가 어떻게해야되는지 전화 해 줄 수 있니? 내가 쿼리를 작성 후 내 반환 데이터는cakephp 2.0 hasmany 관계 데이터 검색
` 배열 (
[0] => Array
(
[Image] => Array
(
[image_id] => 57
[user_id] => 1
[category_id] => 22
[image_title] => scroul
[description] => beutifull natural image for the animal
[keyword] => scrual
[image_price] =>
[image_name] => 7bf4a72509da5906903c84e88228b9dd.jpg
[image_path] => img/uploads/images/original/
[image_available_size] =>
[like] => 12
[size] => 3244
[resolution] => 2162 x 1644
[i_date] => 1348573022
[i_by] => 1
[u_date] => 1348573022
[u_by] => 1
[is_active] => Y
[is_deleted] => N
)
[Comment] => Array
(
[0] => Array
(
[comment_id] => 5
[image_id] => 57
[user_id] => 2
[comment] => socute
[comment_date] => 1348739230
[is_active] => N
[is_deleted] => N
)
)
)
[1] => Array
(
[Image] => Array
(
[image_id] => 56
[user_id] => 1
[category_id] => 22
[image_title] => cute dog
[description] => cute dog looking
[keyword] =>
[image_price] =>
[image_name] => d4af899b0d52cccbec94952a3abd0077.jpg
[image_path] => img/uploads/images/original/
[image_available_size] =>
[like] => 8
[size] => 620
[resolution] => 2592 x 1944
[i_date] => 1348572897
[i_by] => 1
[u_date] => 1348572897
[u_by] => 1
[is_active] => Y
[is_deleted] => N
)
[Comment] => Array
(
[0] => Array
(
[comment_id] => 3
[image_id] => 56
[user_id] => 2
[comment] => ohhhhhhh
[comment_date] => 1348737968
[is_active] => N
[is_deleted] => N
)
)
)
[3] => Array
(
[Image] => Array
(
[image_id] => 55
[user_id] => 1
[category_id] => 22
[image_title] => ships
[description] => ships with beutiful green background
[keyword] => ship,green,animal,nature,background,eating,white ship
[image_price] =>
[image_name] => c0dfc2432ae047e9160f3ef99880fe87.jpg
[image_path] => img/uploads/images/original/
[image_available_size] =>
[like] => 1
[size] => 1831
[resolution] => 2520 x 1944
[i_date] => 1348572846
[i_by] => 1
[u_date] => 1348661976
[u_by] => 1
[is_active] => Y
[is_deleted] => N
)
[Comment] => Array
(
[0] => Array
(
[comment_id] => 2
[image_id] => 55
[user_id] => 2
[comment] => i like it
[comment_date] => 1348737942
[is_active] => Y
[is_deleted] => N
)
[1] => Array
(
[comment_id] => 4
[image_id] => 55
[user_id] => 2
[comment] => good scene
[comment_date] => 1348738004
[is_active] => N
[is_deleted] => N
)
)
)
) 위의 배열
` 해당 이미지의 모든 주석이 있습니다. 나는 여기에 코멘트 목록을 원한다. 단지 코멘트가 필요 없다. 사전에 감사합니다.
으로 추가 속성 'counterScope'를 사용하지만 여전히 내가 한 문제가, 카운터 캐시 범위를 제한 할 수 있습니다. 내 프로젝트에서 사용자가 주석을 추가하면 기본적으로 주석이없는 상태에서 comment_count의 이미지 마스터 값도 1 씩 증가합니다. 관리자가 해당 댓글을 활성화하면 comment_count를 늘리고 싶습니다. 너 나 좀 도와 줄 수있어? –