2
누구나 HABTM 설정에서 카운터 캐시를 사용하는 방법을 알고 계십니까?countercache가있는 Cakephp hasAndBelongsToMany?
- categories
;id, name, test_count
- tests
; id, name
- test_to_categories
; test_id, category_id
누구나 HABTM 설정에서 카운터 캐시를 사용하는 방법을 알고 계십니까?countercache가있는 Cakephp hasAndBelongsToMany?
- categories
;id, name, test_count
- tests
; id, name
- test_to_categories
; test_id, category_id
belongsTo 연결을 통해 조인 모델 (test_to_categories)의 카운터 캐시를 사용하십시오.
그럴 필요가 없다면 커스텀 카운터 메소드를 구현하고 모델의 afterSave()에서 호출하여 카운트를 업데이트해야합니다.
"test_to_categories"는 규칙을 따르지 않습니다. categories_tests 여야합니다. 컨벤션은 이유가 있습니다. ;)
'categories_test'가 아니어야합니까? – Dunhamzzz