- fixing the performance problem on MySQL 5 by using "JOIN xxx USING(cal_id)" instead of ", xxx WHERE xxx.cal_id=egw_cal.cal_id"

- removing the distinkt to fix a MsSQL problem (no distinkt on text columns), double rows will be removed in the php-code anyway
This commit is contained in:
Ralf Becker 2006-03-02 07:02:33 +00:00
parent 3618514657
commit ac89886806

View File

@ -327,23 +327,22 @@ class socal
if ($end) $where[] = 'cal_start < '.(int)$end;
if (!preg_match('/^[a-z_ ,]+$/i',$order)) $order = 'cal_start'; // gard against SQL injunktion
$where[] = '(recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start)';
//_debug_array($where);
if (is_numeric($offset)) // get the total too
{
$this->db->select($this->cal_table,"DISTINCT $this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINKT (MsSQL does not allow it for text-columns)
$this->db->select($this->cal_table,"DISTINCT $this->repeats_table.*,$this->cal_table.cal_id,cal_start,cal_end,cal_recur_date",
$where,__LINE__,__FILE__,false,'',false,0,
",$this->dates_table,$this->user_table LEFT JOIN $this->repeats_table ON $this->user_table.cal_id=$this->repeats_table.cal_id".
" WHERE $this->cal_table.cal_id=$this->dates_table.cal_id AND $this->cal_table.cal_id=$this->user_table.cal_id AND ".
"(recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start)");
"JOIN $this->dates_table USING(cal_id) JOIN $this->user_table USING(cal_id) LEFT JOIN $this->repeats_table USING(cal_id)");
$this->total = $this->db->num_rows();
}
$this->db->select($this->cal_table,"DISTINCT $this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
}
$this->db->select($this->cal_table,"$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
$where,__LINE__,__FILE__,$offset,'ORDER BY '.$order,false,$num_rows,
",$this->dates_table,$this->user_table LEFT JOIN $this->repeats_table ON $this->user_table.cal_id=$this->repeats_table.cal_id".
" WHERE $this->cal_table.cal_id=$this->dates_table.cal_id AND $this->cal_table.cal_id=$this->user_table.cal_id AND ".
"(recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start)");
"JOIN $this->dates_table USING(cal_id) JOIN $this->user_table USING(cal_id) LEFT JOIN $this->repeats_table USING(cal_id)");
$events = $ids = $recur_dates = $recur_ids = array();
while (($row =& $this->db->row(true,'cal_')))