public static function SetNewLogTime($state, $dateTime) { try { $con = Propel::getConnection(); $scheduled = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play'); if ($state == 'L' && $scheduled == 'on') { self::SetEndTime('S', $dateTime); } /* Only insert new state if last log * has ended */ $sql_select = "SELECT max(id) from CC_LIVE_LOG" . " WHERE (state='L' and end_time is NULL) or (state='S' and end_time is NULL)"; $id = $con->query($sql_select)->fetchColumn(0); if ($id == null) { $sql_insert = "INSERT INTO CC_LIVE_LOG (state, start_time)" . " VALUES ('{$state}', '{$dateTime->format("Y-m-d H:i:s")}')"; $con->exec($sql_insert); if ($state == "S") { // if scheduled play source is getting broadcasted Application_Model_Schedule::UpdateBrodcastedStatus($dateTime, 1); } } } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); Logging::info("SetNewLogTime - Could not connect to database."); exit; } }
public static function SetNewLogTime($state, $dateTime) { try { $scheduled = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play'); if ($state == 'L' && $scheduled == 'on') { self::SetEndTime('S', $dateTime); } /* Only insert new state if last log * has ended */ $sql_select = "SELECT max(id) from CC_LIVE_LOG" . " WHERE (state= :state1 and end_time is NULL) or (state= :state2 and end_time is NULL)"; $params = array(":state1" => 'L', ":state2" => 'S'); $id = Application_Common_Database::prepareAndExecute($sql_select, $params, Application_Common_Database::COLUMN); if ($id == null) { $sql_insert = "INSERT INTO CC_LIVE_LOG (state, start_time)" . " VALUES (:state, :start)"; $params = array(':state' => $state, ':start' => $dateTime->format("Y-m-d H:i:s")); Application_Common_Database::prepareAndExecute($sql_insert, $params, Application_Common_Database::EXECUTE); if ($state == "S") { // if scheduled play source is getting broadcasted Application_Model_Schedule::UpdateBrodcastedStatus($dateTime, 1); } } } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); Logging::info("SetNewLogTime - Could not connect to database."); exit; } }