Adapted method active() in Ampel_model

. Added parameter dauerampel
. Set both params to default null to have real usage of boolean param in
the query.
This commit is contained in:
Cris
2020-04-28 16:31:35 +02:00
parent 9f42beaeb3
commit fc2845ad72
+9 -2
View File
@@ -16,9 +16,10 @@ class Ampel_model extends DB_Model
* 1. not after the deadline date
* 2. not before the vorlaufszeit
* @param bool $email If true, then only ampeln are retrieved that are marked to be sent by mail.
* @param bool $dauerampel
* @return array Returns array of objects.
*/
public function active($email = false)
public function active($email = null, $dauerampel = null)
{
$parametersArray = null;
$query = '
@@ -26,11 +27,17 @@ class Ampel_model extends DB_Model
FROM public.tbl_ampel
WHERE';
if ($email === true)
if (is_bool($email))
{
$parametersArray['email'] = $email;
$query .= ' email = ? AND';
}
if (is_bool($dauerampel))
{
$parametersArray['dauerampel'] = $dauerampel;
$query .= ' dauerampel = ? AND';
}
$query .= '(
(NOW()<(deadline+(COALESCE(verfallszeit,0) || \' days\')::interval)::date)