CC-2991: Repeating a show is broken

This commit is contained in:
Martin Konecny 2011-10-24 13:46:16 -04:00
parent ca757d0fc0
commit 858990eb8c
8 changed files with 376 additions and 260 deletions

View file

@ -172,6 +172,20 @@ class Application_Model_DateHelper
return $totalSeconds;
}
public static function ConvertToUtcDateTime($p_dateString, $timezone){
$dateTime = new DateTime($p_dateString, new DateTimeZone($timezone));
$dateTime->setTimezone(new DateTimeZone("UTC"));
return $dateTime;
}
public static function ConvertToSpecificTimezoneDateTime($p_dateString, $timezone){
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
$dateTime->setTimezone(new DateTimeZone($timezone));
return $dateTime;
}
public static function ConvertToLocalDateTime($p_dateString){
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
$dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));

View file

@ -725,7 +725,8 @@ class Application_Model_Show {
public static function create($data)
{
$utcStartDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
$startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
$utcStartDateTime = clone $startDateTime;
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
if ($data['add_show_no_end']) {
@ -733,18 +734,20 @@ class Application_Model_Show {
}
else if ($data['add_show_repeats']) {
$endDateTime = new DateTime($data['add_show_end_date']);
$endDateTime->setTimezone(new DateTimeZone('UTC'));
//$endDateTime->setTimezone(new DateTimeZone('UTC'));
$endDateTime->add(new DateInterval("P1D"));
$endDate = $endDateTime->format("Y-m-d");
}
else {
$endDateTime = new DateTime($data['add_show_start_date']);
$endDateTime->setTimezone(new DateTimeZone('UTC'));
//$endDateTime->setTimezone(new DateTimeZone('UTC'));
$endDateTime->add(new DateInterval("P1D"));
$endDate = $endDateTime->format("Y-m-d");
}
//only want the day of the week from the start date.
//What we are doing here is checking if the show repeats or if
//any repeating days have been checked. If not, then by default
//the "selected" DOW is the initial day.
$startDow = date("w", $utcStartDateTime->getTimestamp());
if (!$data['add_show_repeats']) {
$data['add_show_day_check'] = array($startDow);
@ -786,9 +789,10 @@ class Application_Model_Show {
//don't set day for monthly repeat type, it's invalid.
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){
$showDay = new CcShowDays();
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
$showDay->setDbFirstShow($startDateTime->format("Y-m-d"));
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($utcStartDateTime->format("H:i:s"));
$showDay->setDbStartTime($startDateTime->format("H:i:s"));
$showDay->setDbTimezone(date_default_timezone_get());
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbRepeatType($repeatType);
$showDay->setDbShowId($showId);
@ -796,19 +800,22 @@ class Application_Model_Show {
$showDay->save();
} else {
foreach ($data['add_show_day_check'] as $day) {
$daysAdd=0;
$startDateTimeClone = clone $startDateTime;
if ($startDow !== $day){
if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
$utcStartDateTime->add(new DateInterval("P".$daysAdd."D"));
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
}
if (is_null($endDate) || $utcStartDateTime->getTimestamp() <= $endDateTime->getTimestamp()) {
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
$showDay->setDbFirstShow($startDateTimeClone->format("Y-m-d"));
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($utcStartDateTime->format("H:i"));
$showDay->setDbStartTime($startDateTimeClone->format("H:i"));
$showDay->setDbTimezone(date_default_timezone_get());
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbDay($day);
$showDay->setDbRepeatType($repeatType);
@ -875,6 +882,223 @@ class Application_Model_Show {
return $showId;
}
/**
* Generate repeating show instances for a single show up to the given date.
* If no date is given, use the one in the user's preferences, which is stored
* automatically by FullCalendar as the furthest date in the future the user
* has looked at.
*
* @param int $p_showId
* @param string $p_endTimestamp
* In the format "YYYY-MM-DD HH:mm:ss, non-UTC"
*/
public static function populateShowUntil($p_showId, $p_endTimestamp = NULL)
{
global $CC_DBC;
if (is_null($p_endTimestamp)) {
$p_endTimestamp = Application_Model_Preference::GetShowsPopulatedUntil();
if ($p_endTimestamp == "") {
$today_timestamp = date("Y-m-d");
Application_Model_Preference::SetShowsPopulatedUntil($today_timestamp);
}
}
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
$res = $CC_DBC->GetAll($sql);
foreach ($res as $showRow) {
Application_Model_Show::populateShow($showRow, $p_endTimestamp);
}
}
private static function populateShow($p_showRow, $p_endTimestamp) {
if($p_showRow["repeat_type"] == -1) {
Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_endTimestamp);
}
else if($p_showRow["repeat_type"] == 0) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '7 days');
}
else if($p_showRow["repeat_type"] == 1) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '14 days');
}
else if($p_showRow["repeat_type"] == 2) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '1 month');
}
Application_Model_RabbitMq::PushSchedule();
}
//for a show with repeat_type == -1
private static function populateNonRepeatingShow($p_showRow, $end_timestamp)
{
global $CC_DBC;
$show_id = $p_showRow["show_id"];
$first_show = $p_showRow["first_show"]; //non-UTC
$start_time = $p_showRow["start_time"]; //non-UTC
$duration = $p_showRow["duration"];
$day = $p_showRow["day"];
$record = $p_showRow["record"];
$start = $first_show." ".$start_time;
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
if (strtotime($utcStart) < strtotime($end_timestamp)) {
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
$utcEnd = $CC_DBC->GetOne($sql);
$date = new Application_Model_DateHelper();
$currentUtcTimestamp = $date->getUtcTimestamp();
$show = new Application_Model_Show($show_id);
if ($show->hasInstance()){
$ccShowInstance = $show->getInstance();
$newInstance = false;
}
else {
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStart);
$ccShowInstance->setDbEnds($utcEnd);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
}
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new Application_Model_ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql);
foreach($rebroadcasts as $rebroadcast) {
$timeinfo = explode(" ", $utcStart);
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentUtcTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
}
}
//for a show with repeat_type == 0,1,2
private static function populateRepeatingShow($p_showRow, $end_timestamp, $interval)
{
global $CC_DBC;
$show_id = $p_showRow["show_id"];
$next_pop_date = $p_showRow["next_pop_date"];
$first_show = $p_showRow["first_show"]; //non-UTC
$last_show = $p_showRow["last_show"]; //non-UTC
$start_time = $p_showRow["start_time"]; //non-UTC
$duration = $p_showRow["duration"];
$day = $p_showRow["day"];
$record = $p_showRow["record"];
$timezone = $p_showRow["timezone"];
if(isset($next_pop_date)) {
$utcStart = $next_pop_date." ".$start_time;
} else {
$start = $first_show." ".$start_time;
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Application_Model_Show($show_id);
$date = new Application_Model_DateHelper();
$currentUtcTimestamp = $date->getUtcTimestamp();
while(strtotime($utcStart) <= strtotime($end_timestamp) && (strtotime($utcStart) < strtotime($last_show) || is_null($last_show))) {
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
$utcEnd = $CC_DBC->GetOne($sql);
if ($show->hasInstanceOnDate($utcStart)){
$ccShowInstance = $show->getInstanceOnDate($utcStart);
$newInstance = false;
} else {
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
/* When editing the start/end time of a repeating show, we don't want to
* change shows that started in the past. So check the start time.
*/
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStart);
$ccShowInstance->setDbEnds($utcEnd);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
}
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new Application_Model_ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
foreach($rebroadcasts as $rebroadcast) {
$timeinfo = explode(" ", $utcStart);
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentUtcTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
$start = $CC_DBC->GetOne($sql);
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
}
Application_Model_Show::setNextPop($utcStart, $show_id, $day);
}
/**
* Get all the show instances in the given time range.
*
@ -943,209 +1167,6 @@ class Application_Model_Show {
->save();
}
//for a show with repeat_type == -1
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp)
{
global $CC_DBC;
$next_date = $first_show." ".$start_time;
if (strtotime($next_date) < strtotime($end_timestamp)) {
$start = $next_date;
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
$end = $CC_DBC->GetOne($sql);
$date = new Application_Model_DateHelper();
$currentTimestamp = $date->getTimestamp();
$show = new Application_Model_Show($show_id);
if ($show->hasInstance()){
$ccShowInstance = $show->getInstance();
$newInstance = false;
}
else {
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($start);
$ccShowInstance->setDbEnds($end);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
}
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new Application_Model_ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql);
foreach($rebroadcasts as $rebroadcast) {
$timeinfo = explode(" ", $start);
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
}
Application_Model_RabbitMq::PushSchedule();
}
//for a show with repeat_type == 0,1,2
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
$start_time, $duration, $day, $record, $end_timestamp, $interval)
{
global $CC_DBC;
if(isset($next_pop_date)) {
$next_date = $next_pop_date." ".$start_time;
}
else {
$next_date = $first_show." ".$start_time;
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Application_Model_Show($show_id);
$date = new Application_Model_DateHelper();
$currentTimestamp = $date->getTimestamp();
while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
$start = $next_date;
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
$end = $CC_DBC->GetOne($sql);
if ($show->hasInstanceOnDate($start)){
$ccShowInstance = $show->getInstanceOnDate($start);
$newInstance = false;
} else {
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
/* When editing the start/end time of a repeating show, we don't want to
* change shows that started in the past. So check the start time.
*/
if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($start);
$ccShowInstance->setDbEnds($end);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
}
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new Application_Model_ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
foreach($rebroadcasts as $rebroadcast) {
$timeinfo = explode(" ", $next_date);
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
$next_date = $CC_DBC->GetOne($sql);
}
Application_Model_Show::setNextPop($next_date, $show_id, $day);
Application_Model_RabbitMq::PushSchedule();
}
private static function populateShow($repeatType, $show_id, $next_pop_date,
$first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) {
if($repeatType == -1) {
Application_Model_Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp);
}
else if($repeatType == 0) {
Application_Model_Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
$start_time, $duration, $day, $record, $end_timestamp, '7 days');
}
else if($repeatType == 1) {
Application_Model_Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
$start_time, $duration, $day, $record, $end_timestamp, '14 days');
}
else if($repeatType == 2) {
Application_Model_Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
$start_time, $duration, $day, $record, $end_timestamp, '1 month');
}
}
/**
* Generate repeating show instances for a single show up to the given date.
* If no date is given, use the one in the user's preferences, which is stored
* automatically by FullCalendar as the furthest date in the future the user
* has looked at.
*
* @param int $p_showId
* @param string $p_date
* In the format "YYYY-MM-DD HH:mm:ss"
*/
public static function populateShowUntil($p_showId, $p_date = NULL)
{
global $CC_DBC;
if (is_null($p_date)) {
$p_date = Application_Model_Preference::GetShowsPopulatedUntil();
if ($p_date == "") {
$today_timestamp = date("Y-m-d");
Application_Model_Preference::SetShowsPopulatedUntil($today_timestamp);
}
}
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
$res = $CC_DBC->GetAll($sql);
foreach ($res as $row) {
Application_Model_Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_date);
}
}
/**
* Generate all the repeating shows in the given range.
*
@ -1173,8 +1194,7 @@ class Application_Model_Show {
$res = $CC_DBC->GetAll($sql);
foreach ($res as $row) {
Application_Model_Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_endTimestamp);
Application_Model_Show::populateShow($row, $p_endTimestamp);
}
}

View file

@ -42,6 +42,7 @@ class CcShowDaysTableMap extends TableMap {
$this->addColumn('FIRST_SHOW', 'DbFirstShow', 'DATE', true, null, null);
$this->addColumn('LAST_SHOW', 'DbLastShow', 'DATE', false, null, null);
$this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null);
$this->addColumn('TIMEZONE', 'DbTimezone', 'VARCHAR', true, 255, null);
$this->addColumn('DURATION', 'DbDuration', 'VARCHAR', true, 255, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', false, null, null);
$this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null);

View file

@ -48,6 +48,12 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
*/
protected $start_time;
/**
* The value for the timezone field.
* @var string
*/
protected $timezone;
/**
* The value for the duration field.
* @var string
@ -234,6 +240,16 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
}
}
/**
* Get the [timezone] column value.
*
* @return string
*/
public function getDbTimezone()
{
return $this->timezone;
}
/**
* Get the [duration] column value.
*
@ -484,6 +500,26 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
return $this;
} // setDbStartTime()
/**
* Set the value of [timezone] column.
*
* @param string $v new value
* @return CcShowDays The current object (for fluent API support)
*/
public function setDbTimezone($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->timezone !== $v) {
$this->timezone = $v;
$this->modifiedColumns[] = CcShowDaysPeer::TIMEZONE;
}
return $this;
} // setDbTimezone()
/**
* Set the value of [duration] column.
*
@ -677,12 +713,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->first_show = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->last_show = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->start_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->duration = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->day = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->repeat_type = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->next_pop_date = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->show_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
$this->record = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
$this->timezone = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->duration = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->day = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->repeat_type = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->next_pop_date = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
$this->record = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null;
$this->resetModified();
$this->setNew(false);
@ -691,7 +728,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 10; // 10 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 11; // 11 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowDays object", $e);
@ -1031,21 +1068,24 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
return $this->getDbStartTime();
break;
case 4:
return $this->getDbDuration();
return $this->getDbTimezone();
break;
case 5:
return $this->getDbDay();
return $this->getDbDuration();
break;
case 6:
return $this->getDbRepeatType();
return $this->getDbDay();
break;
case 7:
return $this->getDbNextPopDate();
return $this->getDbRepeatType();
break;
case 8:
return $this->getDbShowId();
return $this->getDbNextPopDate();
break;
case 9:
return $this->getDbShowId();
break;
case 10:
return $this->getDbRecord();
break;
default:
@ -1076,12 +1116,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$keys[1] => $this->getDbFirstShow(),
$keys[2] => $this->getDbLastShow(),
$keys[3] => $this->getDbStartTime(),
$keys[4] => $this->getDbDuration(),
$keys[5] => $this->getDbDay(),
$keys[6] => $this->getDbRepeatType(),
$keys[7] => $this->getDbNextPopDate(),
$keys[8] => $this->getDbShowId(),
$keys[9] => $this->getDbRecord(),
$keys[4] => $this->getDbTimezone(),
$keys[5] => $this->getDbDuration(),
$keys[6] => $this->getDbDay(),
$keys[7] => $this->getDbRepeatType(),
$keys[8] => $this->getDbNextPopDate(),
$keys[9] => $this->getDbShowId(),
$keys[10] => $this->getDbRecord(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -1131,21 +1172,24 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->setDbStartTime($value);
break;
case 4:
$this->setDbDuration($value);
$this->setDbTimezone($value);
break;
case 5:
$this->setDbDay($value);
$this->setDbDuration($value);
break;
case 6:
$this->setDbRepeatType($value);
$this->setDbDay($value);
break;
case 7:
$this->setDbNextPopDate($value);
$this->setDbRepeatType($value);
break;
case 8:
$this->setDbShowId($value);
$this->setDbNextPopDate($value);
break;
case 9:
$this->setDbShowId($value);
break;
case 10:
$this->setDbRecord($value);
break;
} // switch()
@ -1176,12 +1220,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
if (array_key_exists($keys[1], $arr)) $this->setDbFirstShow($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbLastShow($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbStartTime($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbDuration($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDay($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbRepeatType($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbNextPopDate($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbShowId($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbRecord($arr[$keys[9]]);
if (array_key_exists($keys[4], $arr)) $this->setDbTimezone($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDuration($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbDay($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbRepeatType($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbNextPopDate($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setDbRecord($arr[$keys[10]]);
}
/**
@ -1197,6 +1242,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowDaysPeer::FIRST_SHOW)) $criteria->add(CcShowDaysPeer::FIRST_SHOW, $this->first_show);
if ($this->isColumnModified(CcShowDaysPeer::LAST_SHOW)) $criteria->add(CcShowDaysPeer::LAST_SHOW, $this->last_show);
if ($this->isColumnModified(CcShowDaysPeer::START_TIME)) $criteria->add(CcShowDaysPeer::START_TIME, $this->start_time);
if ($this->isColumnModified(CcShowDaysPeer::TIMEZONE)) $criteria->add(CcShowDaysPeer::TIMEZONE, $this->timezone);
if ($this->isColumnModified(CcShowDaysPeer::DURATION)) $criteria->add(CcShowDaysPeer::DURATION, $this->duration);
if ($this->isColumnModified(CcShowDaysPeer::DAY)) $criteria->add(CcShowDaysPeer::DAY, $this->day);
if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) $criteria->add(CcShowDaysPeer::REPEAT_TYPE, $this->repeat_type);
@ -1267,6 +1313,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$copyObj->setDbFirstShow($this->first_show);
$copyObj->setDbLastShow($this->last_show);
$copyObj->setDbStartTime($this->start_time);
$copyObj->setDbTimezone($this->timezone);
$copyObj->setDbDuration($this->duration);
$copyObj->setDbDay($this->day);
$copyObj->setDbRepeatType($this->repeat_type);
@ -1374,6 +1421,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->first_show = null;
$this->last_show = null;
$this->start_time = null;
$this->timezone = null;
$this->duration = null;
$this->day = null;
$this->repeat_type = null;

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowDaysPeer {
const TM_CLASS = 'CcShowDaysTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 10;
const NUM_COLUMNS = 11;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -43,6 +43,9 @@ abstract class BaseCcShowDaysPeer {
/** the column name for the START_TIME field */
const START_TIME = 'cc_show_days.START_TIME';
/** the column name for the TIMEZONE field */
const TIMEZONE = 'cc_show_days.TIMEZONE';
/** the column name for the DURATION field */
const DURATION = 'cc_show_days.DURATION';
@ -77,12 +80,12 @@ abstract class BaseCcShowDaysPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbTimezone', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbTimezone', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::TIMEZONE, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'TIMEZONE', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'timezone', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@ -92,12 +95,12 @@ abstract class BaseCcShowDaysPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbDuration' => 4, 'DbDay' => 5, 'DbRepeatType' => 6, 'DbNextPopDate' => 7, 'DbShowId' => 8, 'DbRecord' => 9, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbDuration' => 4, 'dbDay' => 5, 'dbRepeatType' => 6, 'dbNextPopDate' => 7, 'dbShowId' => 8, 'dbRecord' => 9, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::DURATION => 4, self::DAY => 5, self::REPEAT_TYPE => 6, self::NEXT_POP_DATE => 7, self::SHOW_ID => 8, self::RECORD => 9, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'DURATION' => 4, 'DAY' => 5, 'REPEAT_TYPE' => 6, 'NEXT_POP_DATE' => 7, 'SHOW_ID' => 8, 'RECORD' => 9, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'duration' => 4, 'day' => 5, 'repeat_type' => 6, 'next_pop_date' => 7, 'show_id' => 8, 'record' => 9, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbTimezone' => 4, 'DbDuration' => 5, 'DbDay' => 6, 'DbRepeatType' => 7, 'DbNextPopDate' => 8, 'DbShowId' => 9, 'DbRecord' => 10, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbTimezone' => 4, 'dbDuration' => 5, 'dbDay' => 6, 'dbRepeatType' => 7, 'dbNextPopDate' => 8, 'dbShowId' => 9, 'dbRecord' => 10, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::TIMEZONE => 4, self::DURATION => 5, self::DAY => 6, self::REPEAT_TYPE => 7, self::NEXT_POP_DATE => 8, self::SHOW_ID => 9, self::RECORD => 10, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'TIMEZONE' => 4, 'DURATION' => 5, 'DAY' => 6, 'REPEAT_TYPE' => 7, 'NEXT_POP_DATE' => 8, 'SHOW_ID' => 9, 'RECORD' => 10, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'timezone' => 4, 'duration' => 5, 'day' => 6, 'repeat_type' => 7, 'next_pop_date' => 8, 'show_id' => 9, 'record' => 10, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@ -173,6 +176,7 @@ abstract class BaseCcShowDaysPeer {
$criteria->addSelectColumn(CcShowDaysPeer::FIRST_SHOW);
$criteria->addSelectColumn(CcShowDaysPeer::LAST_SHOW);
$criteria->addSelectColumn(CcShowDaysPeer::START_TIME);
$criteria->addSelectColumn(CcShowDaysPeer::TIMEZONE);
$criteria->addSelectColumn(CcShowDaysPeer::DURATION);
$criteria->addSelectColumn(CcShowDaysPeer::DAY);
$criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE);
@ -184,6 +188,7 @@ abstract class BaseCcShowDaysPeer {
$criteria->addSelectColumn($alias . '.FIRST_SHOW');
$criteria->addSelectColumn($alias . '.LAST_SHOW');
$criteria->addSelectColumn($alias . '.START_TIME');
$criteria->addSelectColumn($alias . '.TIMEZONE');
$criteria->addSelectColumn($alias . '.DURATION');
$criteria->addSelectColumn($alias . '.DAY');
$criteria->addSelectColumn($alias . '.REPEAT_TYPE');

View file

@ -10,6 +10,7 @@
* @method CcShowDaysQuery orderByDbFirstShow($order = Criteria::ASC) Order by the first_show column
* @method CcShowDaysQuery orderByDbLastShow($order = Criteria::ASC) Order by the last_show column
* @method CcShowDaysQuery orderByDbStartTime($order = Criteria::ASC) Order by the start_time column
* @method CcShowDaysQuery orderByDbTimezone($order = Criteria::ASC) Order by the timezone column
* @method CcShowDaysQuery orderByDbDuration($order = Criteria::ASC) Order by the duration column
* @method CcShowDaysQuery orderByDbDay($order = Criteria::ASC) Order by the day column
* @method CcShowDaysQuery orderByDbRepeatType($order = Criteria::ASC) Order by the repeat_type column
@ -21,6 +22,7 @@
* @method CcShowDaysQuery groupByDbFirstShow() Group by the first_show column
* @method CcShowDaysQuery groupByDbLastShow() Group by the last_show column
* @method CcShowDaysQuery groupByDbStartTime() Group by the start_time column
* @method CcShowDaysQuery groupByDbTimezone() Group by the timezone column
* @method CcShowDaysQuery groupByDbDuration() Group by the duration column
* @method CcShowDaysQuery groupByDbDay() Group by the day column
* @method CcShowDaysQuery groupByDbRepeatType() Group by the repeat_type column
@ -43,6 +45,7 @@
* @method CcShowDays findOneByDbFirstShow(string $first_show) Return the first CcShowDays filtered by the first_show column
* @method CcShowDays findOneByDbLastShow(string $last_show) Return the first CcShowDays filtered by the last_show column
* @method CcShowDays findOneByDbStartTime(string $start_time) Return the first CcShowDays filtered by the start_time column
* @method CcShowDays findOneByDbTimezone(string $timezone) Return the first CcShowDays filtered by the timezone column
* @method CcShowDays findOneByDbDuration(string $duration) Return the first CcShowDays filtered by the duration column
* @method CcShowDays findOneByDbDay(int $day) Return the first CcShowDays filtered by the day column
* @method CcShowDays findOneByDbRepeatType(int $repeat_type) Return the first CcShowDays filtered by the repeat_type column
@ -54,6 +57,7 @@
* @method array findByDbFirstShow(string $first_show) Return CcShowDays objects filtered by the first_show column
* @method array findByDbLastShow(string $last_show) Return CcShowDays objects filtered by the last_show column
* @method array findByDbStartTime(string $start_time) Return CcShowDays objects filtered by the start_time column
* @method array findByDbTimezone(string $timezone) Return CcShowDays objects filtered by the timezone column
* @method array findByDbDuration(string $duration) Return CcShowDays objects filtered by the duration column
* @method array findByDbDay(int $day) Return CcShowDays objects filtered by the day column
* @method array findByDbRepeatType(int $repeat_type) Return CcShowDays objects filtered by the repeat_type column
@ -279,6 +283,28 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria
return $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime, $comparison);
}
/**
* Filter the query on the timezone column
*
* @param string $dbTimezone The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowDaysQuery The current query, for fluid interface
*/
public function filterByDbTimezone($dbTimezone = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbTimezone)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbTimezone)) {
$dbTimezone = str_replace('*', '%', $dbTimezone);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcShowDaysPeer::TIMEZONE, $dbTimezone, $comparison);
}
/**
* Filter the query on the duration column
*

View file

@ -169,6 +169,7 @@
<column name="first_show" phpName="DbFirstShow" type="DATE" required="true"/>
<column name="last_show" phpName="DbLastShow" type="DATE" required="false"/>
<column name="start_time" phpName="DbStartTime" type="TIME" required="true"/>
<column name="timezone" phpName="DbTimezone" type="VARCHAR" required="true"/>
<column name="duration" phpName="DbDuration" type="VARCHAR" required="true"/>
<column name="day" phpName="DbDay" type="TINYINT" required="false"/>
<column name="repeat_type" phpName="DbRepeatType" type="TINYINT" required="true"/>

View file

@ -216,6 +216,7 @@ CREATE TABLE "cc_show_days"
"first_show" DATE NOT NULL,
"last_show" DATE,
"start_time" TIME NOT NULL,
"timezone" VARCHAR(255) NOT NULL,
"duration" VARCHAR(255) NOT NULL,
"day" INT2,
"repeat_type" INT2 NOT NULL,