global $wgDBtype;
if ($wgDBtype == "mysql") // "condition" is a reserved word in mysql
for ($i = 0; $i != count($columns); ++$i) $columns[$i] = sprintf('`%s`', $columns[$i]);
- $res = $dbr->select('wrreport', $columns, $conditions, $fname = 'Database::select', $options = array('ORDER BY' => 'date_report desc, date_entry desc'));
+ $res = $dbr->select('wrreport', $columns, $conditions, 'wrReportGetReports', array('ORDER BY' => 'date_report desc, date_entry desc'));
$result = array();
while ($row = $dbr->fetchRow($res)) $result[] = $row;
$dbr->freeResult($res);
}
-/// \brief It returns an array of the "condition" (as number) and the date of the "most recent" report of the specified page (to decode as list($condition, $date);
+/// \brief It returns an array of the "condition" (as number) and the date of the "most recent" report of the specified page (to decode as list($condition, $date));
///
/// If no condition is present, array(NULL, NULL) is returned
function wrReportConditionRender($page_title) {
$dbr = wfGetDB(DB_SLAVE);
$cond = 'condition';
global $wgDBtype;
+ // select wrreport.id as report_id, `condition`, date_report from wrreport where page_title='Axamer Lizum' and `condition` is not null and date_invalid > now() and delete_date is null order by date_report desc, date_entry desc limit 1;
if ($wgDBtype == "mysql") $cond = "`$cond`"; // "condition" is a reserved word in mysql
- $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')
+ );
if ($res->numRows() <= 0) {
$dbr->freeResult($res);
return array(NULL, NULL);