Hi. I have a model Author that HAS_MANY Books . Each Book HAS_MANY Likes and HAS_MANY Readers.
I want to to fetch only those books that have more then one Like and more than one Reader.
I’m trying to do so:
$criteria = new CDbCriteria(array(
'with' => array(
'books' => array(
'with' => array('likes', 'readers'),
'together' => false,
// what's here ??
'having' => 'COUNT(likes) > 0 AND count(readers) > 0' // ??
)
)
));
$author = Author::model()->findByPk($id, $criteria);
Likes and readers are HAS_MANY relations, not STAT