- if(!empty($q['dup_check'])){
- $et = DB_DataObject::factory($tn);
- $this->_join .= "LEFT JOIN {$et->tableName()} AS evet ON (evet.id=Events.id)";
- $this->selectAdd("(select count(*)+1 from Events where Events.dup_id = evet.id) as cnt ");
- $this->selectAs($et,'%s','evet');
- $this->having('Events.dup_id = 0 ');
-
+ if(!empty($q['_with_dupe_count'])){
+ $this->dupe_id = 0;
+ $this->selectAdd("(select count(*)+1 from Events ev_cnt where ev_cnt.dupe_id = {$tn}.id) as dupe_count");