mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
reverted to old query for mssql and mysql < 4
This commit is contained in:
parent
c230fb81c4
commit
aa2161d4c2
@ -328,47 +328,50 @@ class socal
|
|||||||
|
|
||||||
if (!preg_match('/^[a-z_ ,]+$/i',$order)) $order = 'cal_start'; // gard against SQL injunktion
|
if (!preg_match('/^[a-z_ ,]+$/i',$order)) $order = 'cal_start'; // gard against SQL injunktion
|
||||||
|
|
||||||
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
|
if ($this->db->capabilities['distinct_on_text'] && $this->capabilities['union'])
|
||||||
$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)",
|
|
||||||
'cols' => "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
|
|
||||||
'where' => $where,
|
|
||||||
);
|
|
||||||
$selects = array($select,$select);
|
|
||||||
$selects[0]['where'][] = 'recur_type IS NULL AND cal_recur_date=0';
|
|
||||||
$selects[1]['where'][] = 'cal_recur_date=cal_start';
|
|
||||||
|
|
||||||
if (is_numeric($offset)) // get the total too
|
|
||||||
{
|
{
|
||||||
// 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)
|
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
|
||||||
$selects[0]['cols'] = $selects[1]['cols'] = "DISTINCT $this->repeats_table.*,$this->cal_table.cal_id,cal_start,cal_end,cal_recur_date";
|
$select = array(
|
||||||
|
'table' => $this->cal_table,
|
||||||
|
'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,
|
||||||
|
);
|
||||||
|
$selects = array($select,$select);
|
||||||
|
$selects[0]['where'][] = 'recur_type IS NULL AND cal_recur_date=0';
|
||||||
|
$selects[1]['where'][] = 'cal_recur_date=cal_start';
|
||||||
|
|
||||||
$this->db->union($selects,__LINE__,__FILE__);
|
if (is_numeric($offset)) // get the total too
|
||||||
$this->total = $this->db->num_rows();
|
{
|
||||||
|
// 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)
|
||||||
|
$selects[0]['cols'] = $selects[1]['cols'] = "DISTINCT $this->repeats_table.*,$this->cal_table.cal_id,cal_start,cal_end,cal_recur_date";
|
||||||
|
|
||||||
$selects[0]['cols'] = $selects[1]['cols'] = $select['cols']; // restore the original cols
|
$this->db->union($selects,__LINE__,__FILE__);
|
||||||
|
$this->total = $this->db->num_rows();
|
||||||
|
|
||||||
|
$selects[0]['cols'] = $selects[1]['cols'] = $select['cols']; // restore the original cols
|
||||||
|
}
|
||||||
|
$this->db->union($selects,__LINE__,__FILE__,$order,$offset,$num_rows);
|
||||||
}
|
}
|
||||||
$this->db->union($selects,__LINE__,__FILE__,$order,$offset,$num_rows);
|
else // MsSQL oder MySQL 3.23
|
||||||
|
|
||||||
/* original query
|
|
||||||
$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
|
|
||||||
{
|
{
|
||||||
// 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)
|
$where[] = '(recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start)';
|
||||||
$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)");
|
|
||||||
|
|
||||||
$this->total = $this->db->num_rows();
|
//_debug_array($where);
|
||||||
|
if (is_numeric($offset)) // get the total too
|
||||||
|
{
|
||||||
|
// 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 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 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->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)");
|
|
||||||
*/
|
|
||||||
$events = $ids = $recur_dates = $recur_ids = array();
|
$events = $ids = $recur_dates = $recur_ids = array();
|
||||||
while (($row =& $this->db->row(true,'cal_')))
|
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)
|
// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
|
||||||
$ids = array();
|
$ids = array();
|
||||||
$this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
|
$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)))
|
while(($row = $this->db->row(true)))
|
||||||
{
|
{
|
||||||
$ids[] = $row['cal_id'];
|
$ids[] = $row['cal_id'];
|
||||||
|
Loading…
Reference in New Issue
Block a user