- $res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array('page_title' => $page_title, "$cond is not null", 'date_invalid > now()'));
- // select condition, date_report from wrreport where id = (select max(wrreport.id) as max from wrreport where page_title='Birgitzer Alm (vom Adelshof)' and date_invalid > now() and condition is not null);
- if ($res->numRows() <= 0) {
- $dbr->freeResult($res);
- return array(NULL, NULL);
- }
- $row = $dbr->fetchObject($res);
- $dbr->freeResult($res);
- $res = $dbr->select('wrreport', array($cond, 'date_report'), array('id' => $row->max));
+ $res = $dbr->select(
+ 'wrreport',
+ array('wrreport.id as report_id', $cond, 'date_report'),
+ array('page_title' => $page_title, "$cond is not null", 'date_invalid > now()', 'delete_date is null'),
+ 'wrReportConditionRender',
+ array('ORDER BY' => 'date_report desc, date_entry desc', 'LIMIT' => '1')
+ );