Consider three tables: taxon (list of species), place (list of localities), record (contains list of species and localities). I wish to generate a unique list of species from a particular place. Note that there can be more than one species record from a particular locality but I only want the presence of the species, not every record. Here’s what I’ve tried:
$criteria = new CDBCriteria();
$criteria->distinct = TRUE;
$criteria->select = 't.taxon_id';
$criteria->with = array('formattedTaxon');
$criteria->addInCondition('place_id', $this->getPlaceDescendants());
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'sort' => array(
'defaultOrder' => '"formattedTaxon".name',
),
));
It returns every record. FormattedTaxon is a view that is simply there to allow me to sort the list by the taxon name. If I remove the "with" and the "sort", it works!
What am I doing wrong?
Thanks!
B