Code: Select all
//We split what we are passed into an ID and a time difference
$array = explode(',', $array);
$id = $array[0];
$time_difference = $array[1];
$conflict = true;
//We will loop through and continually update until we are out of conflicts
while($conflict = true)
{
//Take our ID and update it with the id an time difference we have
$this->db->sql = "UPDATE schedule SET start_time = start_time + ".$time_difference.", end_time = end_time + ".$time_difference." WHERE id = ".$id;
$check = $this->db->update_record();
//Now get the schedule entry info after it's been updated
$this->get_info($id);
$end_time = $this->end_time;
//Now take this info and check for an additional conflict
$additional = $this->additional_conflicts($end_time);
//If we get a 0 back there is no other conflict
if($additional == 0)
$conflict = false;
else
{
//Else we explode our array to get an id and time difference and continue the loop
$array = explode(',', $additional);
$id = $array[0];
$time_difference = $array[1];
}
}Code: Select all
$this->db->sql = "SELECT
start_time
FROM
tv_schedule
WHERE
channel_id = '".$this->channel_id."' AND
start_time < ".$end_time." AND
end_time > ".$end_time;
$count = $this->db->count_records();
if($count == 0)
return 0;
else
{
$row = $this->db->select_record();
$time_difference = $end_time = $row['start_time'];
return $row['id'].",".$time_difference;
}