- $sSQL .= " from import_polygon_error";
- $sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
- $iDays++;
-
- if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
- if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
- $sSQL .= " order by updated desc limit 1000";
- $aPolygons = chksql($oDB->getAll($sSQL));
+ $sSQL .= ' from import_polygon_error';
+
+ $aWhere = array();
+ if ($iDays) {
+ $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
+ $iDays++;
+ }
+
+ if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
+ if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
+
+ if (!empty($aWhere)) {
+ $sSQL .= ' where '.join(' and ', $aWhere);
+ }
+
+ $sSQL .= ' order by updated desc limit 1000';
+ $aPolygons = $oDB->getAll($sSQL);