Grr PostgreSQL has a different syntax for UPDATE with a JOIN then MySQL, they dont share a syntax working for both

This commit is contained in:
Ralf Becker 2015-04-29 14:20:44 +00:00
parent 1d6499661e
commit f7de88e39c

View File

@ -2396,15 +2396,31 @@ ORDER BY count(*) DESC", __LINE__, __FILE__, 0, 1)->fetch();
// if maximum is bigger then 3 // if maximum is bigger then 3
if ($values[1] > 3) if ($values[1] > 3)
{ {
$GLOBALS['egw_setup']->db->query("UPDATE egw_cal switch($GLOBALS['egw_setup']->db->Type)
{
case 'mysql':
$sql = "UPDATE egw_cal
JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id
SET range_end=NULL SET range_end=NULL
WHERE recur_type=5 AND range_end IS NOT NULL AND ABS(cal_modified-$values[0])<=1", __LINE__, __FILE__); WHERE recur_type=5 AND range_end IS NOT NULL AND ABS(cal_modified-$values[0])<=1";
break;
case 'pgsql':
$sql = "UPDATE egw_cal
SET range_end=NULL
FROM egw_cal AS cal
JOIN egw_cal_repeats ON cal.cal_id=egw_cal_repeats.cal_id
WHERE recur_type=5 AND cal.range_end IS NOT NULL AND ABS(cal.cal_modified-$values[0])<=1";
break;
}
if (isset($sql))
{
$GLOBALS['egw_setup']->db->query($sql, __LINE__, __FILE__);
if (($num = $GLOBALS['egw_setup']->db->affected_rows())) if (($num = $GLOBALS['egw_setup']->db->affected_rows()))
{ {
error_log(__METHOD__."() removed end-date from $num yearly recuring events again."); error_log(__METHOD__."() removed end-date from $num yearly recuring events again.");
} }
} }
}
return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002';
} }