The subject may be a common question but I have a bit more deeper problem. I am a freshman in CakePhp and already googled the issue. Unfortunately I could not find my exact solution.
My database structure is below with two tables and I used cakePhp naming conventions:
- news (id, news_title, news_text, is_active, created, modified)
- news_images (id, news_id, image_src, is_default, created, modified)
Each news has many images. But one image is being selected as default to-be used as a thumbnail in homepage.
In news listing pages, I want to list all news with a thumbnail. Thumbnail means, news_images.is_default=true
So I have to make a hasMany relationship but filtering with is_default=true
If I simply fetched data after hasMany and belongsTo relationship without using any conditions, it's retrieving all images. And I could not succeeded bingModal or container while I am too new to cakePhp.
I would like to request your help. Thanks in advance.

news (id, news_title, news_text, is_active, created, modified, news_images_id)news_images (id, news_id, image_src, created, modified)withnews_images_id(follow CakePHP naming convention) is featured image (for thumbnail) - Do Nhu Vyclass News extends AppModel { public $hasMany = array('news_image' => array( 'conditions' => array('news_image.is_default' => true) ) ); }And NewsImage.phpclass NewsImage extends AppModel{ public $belongsTo = array('News'); }Thanks - hrnsaracpublic $hasMany = array('news_image');NewsImage:public $belongsTo = array('News');Or should News be $hasOne? I could not decided as a freshman? Thanks again. - hrnsarac