X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/mediawiki_extensions/wrreport.git/blobdiff_plain/665bbc949b893f62df1bde0511e07f2d97aab725..b156d161e1caa0a613b5a22a5b351275cca31205:/wrreport.body.php diff --git a/wrreport.body.php b/wrreport.body.php index 4c6ff96..526e44d 100644 --- a/wrreport.body.php +++ b/wrreport.body.php @@ -254,7 +254,7 @@ function wrReportGetReports($conditions, $order) { 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); @@ -262,23 +262,22 @@ function wrReportGetReports($conditions, $order) { } -/// \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);