0 && $diff != 0) { $showIdList = implode(",", $instanceIds); /*$sql = << $diff, ':diff2' => $diff, ':showIds' => $showIdList), 'execute');*/ $sql = "UPDATE cc_schedule " ."SET starts = starts + INTERVAL '$diff sec', " ."ends = ends + INTERVAL '$diff sec' " ."WHERE instance_id IN ($showIdList)"; $con->exec($sql); } } /** * * Removes any time gaps in shows * * @param array $schedIds schedule ids to exclude */ public function removeGaps($showId, $schedIds=null) { $ccShowInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->find(); foreach ($ccShowInstances as $instance) { Logging::info("Removing gaps from show instance #".$instance->getDbId()); //DateTime object $itemStart = $instance->getDbStarts(null); $ccScheduleItems = CcScheduleQuery::create() ->filterByDbInstanceId($instance->getDbId()) ->filterByDbId($schedIds, Criteria::NOT_IN) ->orderByDbStarts() ->find(); foreach ($ccScheduleItems as $ccSchedule) { //DateTime object $itemEnd = $this->findEndTime($itemStart, $ccSchedule->getDbClipLength()); $ccSchedule->setDbStarts($itemStart) ->setDbEnds($itemEnd); $itemStart = $itemEnd; } $ccScheduleItems->save(); } } /** * * Enter description here ... * @param DateTime $instanceStart * @param string $clipLength */ private function findEndTime($instanceStart, $clipLength) { $startEpoch = $instanceStart->format("U.u"); $durationSeconds = Application_Common_DateHelper::playlistTimeToSeconds($clipLength); //add two float numbers to 6 subsecond precision //DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number. $endEpoch = bcadd($startEpoch , (string) $durationSeconds, 6); $dt = DateTime::createFromFormat("U.u", $endEpoch, new DateTimeZone("UTC")); if ($dt === false) { //PHP 5.3.2 problem $dt = DateTime::createFromFormat("U", intval($endEpoch), new DateTimeZone("UTC")); } return $dt; } }