$joins = explode(',',$q['_join']);
$this->selectAdd(); // ???
+ $distinct = false;
foreach($joins as $t) {
$t = preg_replace('/[^a-z_]+/', '', $t); // protection.
if (! in_array($jc, $keys)) {
continue;
}
-
+ if ($distinct) {
- $this->selectAdd( " distinct(join_on_id_{$jtn}.{$jc} ) as on_id_{$jc} ");
+ $this->selectAdd( " join_on_id_{$jtn}.{$jc} as on_id_{$jc} ");
+ } else {
+ $this->selectAdd( " distinct(join_on_id_{$jtn}.{$jc} ) as on_id_{$jc} ");
+ $distinct = true;
+ }
$this->groupBy("on_id_{$jc} ");
$this->whereAdd("join_on_id_{$jtn}.{$jc} IS NOT NULL");
}