Próbuje przerobić poniższe zapytanie:
SELECT a.id, a.news_title, a.news_content, a.news_author, a.news_date, COUNT(b.id) AS news_comments_count, d.user_name FROM news a LEFT JOIN comments b ON b.comment_parent = a.id LEFT JOIN users d ON d.id = a.news_author GROUP BY a.id ORDER BY a.id DESC
na model bez większego powodzenia. Narazie tyle mam:
<?php class News extends AppModel { var $name = 'News'; 'conditions' => '', 'order' => '', 'foreignKey' => 'news_author', 'counterCache' => '' ) ); 'joinTable' => 'comments', 'foreignKey' => 'comment_parent', 'associationForeignKey'=> 'id', 'conditions' => '', 'order' => '', 'limit' => '', 'uniq' => true, 'finderSql' => '', 'deleteQuery'=> '', ) ); } ?>
Pobiera co prawda newsy, autora i komentarze ale wykonuje przy tym 39 zapytań do bazy, czyli tyle ile jest newsów, jakby bylo ich 100 to pewnie by wykonało ~100 zapytań

Liczenia ile komentarzy ma poszczególny news, nie udało mi sie zaimplementować do modelu.
Licze na pomoc...
