reverted to old query for mssql and mysql < 4

This commit is contained in:
Ralf Becker 2006-03-29 07:01:18 +00:00
parent c230fb81c4
commit aa2161d4c2

View File

@ -328,10 +328,12 @@ class socal
if (!preg_match('/^[a-z_ ,]+$/i',$order)) $order = 'cal_start'; // gard against SQL injunktion
if ($this->db->capabilities['distinct_on_text'] && $this->capabilities['union'])
{
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
$select = array(
'table' => $this->cal_table,
'join' => "JOIN $this->dates_table USING(cal_id) JOIN $this->user_table USING(cal_id) LEFT JOIN $this->repeats_table USING(cal_id)",
'join' => "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id",
'cols' => "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
'where' => $where,
);
@ -350,8 +352,9 @@ class socal
$selects[0]['cols'] = $selects[1]['cols'] = $select['cols']; // restore the original cols
}
$this->db->union($selects,__LINE__,__FILE__,$order,$offset,$num_rows);
/* original query
}
else // MsSQL oder MySQL 3.23
{
$where[] = '(recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start)';
//_debug_array($where);
@ -360,15 +363,15 @@ class socal
// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. 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,
"JOIN $this->dates_table USING(cal_id) JOIN $this->user_table USING(cal_id) LEFT JOIN $this->repeats_table USING(cal_id)");
"JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id");
$this->total = $this->db->num_rows();
}
$this->db->select($this->cal_table,($this->db->capabilities['distinct_on_text'] ? 'DISTINCT ' : '').
"$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
$where,__LINE__,__FILE__,$offset,'ORDER BY '.$order,false,$num_rows,
"JOIN $this->dates_table USING(cal_id) JOIN $this->user_table USING(cal_id) LEFT JOIN $this->repeats_table USING(cal_id)");
*/
"JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id");
}
$events = $ids = $recur_dates = $recur_ids = array();
while (($row =& $this->db->row(true,'cal_')))
{
@ -1078,7 +1081,7 @@ ORDER BY cal_user_type, cal_usre_id
// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
$ids = array();
$this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
False,'',False,0,"LEFT JOIN $this->user_table USING (cal_id)");
False,'',False,0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id");
while(($row = $this->db->row(true)))
{
$ids[] = $row['cal_id'];