changes to how shows are created/stored.

This commit is contained in:
naomiaro 2011-02-05 16:00:05 -05:00
parent 42284deb58
commit 89b971b67c
23 changed files with 3228 additions and 532 deletions

View file

@ -36,6 +36,13 @@ return array (
'BaseCcShowPeer' => 'airtime/om/BaseCcShowPeer.php',
'BaseCcShow' => 'airtime/om/BaseCcShow.php',
'BaseCcShowQuery' => 'airtime/om/BaseCcShowQuery.php',
'CcShowInstancesTableMap' => 'airtime/map/CcShowInstancesTableMap.php',
'CcShowInstancesPeer' => 'airtime/CcShowInstancesPeer.php',
'CcShowInstances' => 'airtime/CcShowInstances.php',
'CcShowInstancesQuery' => 'airtime/CcShowInstancesQuery.php',
'BaseCcShowInstancesPeer' => 'airtime/om/BaseCcShowInstancesPeer.php',
'BaseCcShowInstances' => 'airtime/om/BaseCcShowInstances.php',
'BaseCcShowInstancesQuery' => 'airtime/om/BaseCcShowInstancesQuery.php',
'CcShowDaysTableMap' => 'airtime/map/CcShowDaysTableMap.php',
'CcShowDaysPeer' => 'airtime/CcShowDaysPeer.php',
'CcShowDays' => 'airtime/CcShowDays.php',

View file

@ -1,116 +0,0 @@
<?php
// This file generated by Propel 1.5.2 convert-conf target
return array (
'CcAccessTableMap' => 'airtime/map/CcAccessTableMap.php',
'CcAccessPeer' => 'airtime/CcAccessPeer.php',
'CcAccess' => 'airtime/CcAccess.php',
'CcAccessQuery' => 'airtime/CcAccessQuery.php',
'BaseCcAccessPeer' => 'airtime/om/BaseCcAccessPeer.php',
'BaseCcAccess' => 'airtime/om/BaseCcAccess.php',
'BaseCcAccessQuery' => 'airtime/om/BaseCcAccessQuery.php',
'CcBackupTableMap' => 'airtime/map/CcBackupTableMap.php',
'CcBackupPeer' => 'airtime/CcBackupPeer.php',
'CcBackup' => 'airtime/CcBackup.php',
'CcBackupQuery' => 'airtime/CcBackupQuery.php',
'BaseCcBackupPeer' => 'airtime/om/BaseCcBackupPeer.php',
'BaseCcBackup' => 'airtime/om/BaseCcBackup.php',
'BaseCcBackupQuery' => 'airtime/om/BaseCcBackupQuery.php',
'CcFilesTableMap' => 'airtime/map/CcFilesTableMap.php',
'CcFilesPeer' => 'airtime/CcFilesPeer.php',
'CcFiles' => 'airtime/CcFiles.php',
'CcFilesQuery' => 'airtime/CcFilesQuery.php',
'BaseCcFilesPeer' => 'airtime/om/BaseCcFilesPeer.php',
'BaseCcFiles' => 'airtime/om/BaseCcFiles.php',
'BaseCcFilesQuery' => 'airtime/om/BaseCcFilesQuery.php',
'CcPermsTableMap' => 'airtime/map/CcPermsTableMap.php',
'CcPermsPeer' => 'airtime/CcPermsPeer.php',
'CcPerms' => 'airtime/CcPerms.php',
'CcPermsQuery' => 'airtime/CcPermsQuery.php',
'BaseCcPermsPeer' => 'airtime/om/BaseCcPermsPeer.php',
'BaseCcPerms' => 'airtime/om/BaseCcPerms.php',
'BaseCcPermsQuery' => 'airtime/om/BaseCcPermsQuery.php',
'CcShowTableMap' => 'airtime/map/CcShowTableMap.php',
'CcShowPeer' => 'airtime/CcShowPeer.php',
'CcShow' => 'airtime/CcShow.php',
'CcShowQuery' => 'airtime/CcShowQuery.php',
'BaseCcShowPeer' => 'airtime/om/BaseCcShowPeer.php',
'BaseCcShow' => 'airtime/om/BaseCcShow.php',
'BaseCcShowQuery' => 'airtime/om/BaseCcShowQuery.php',
'CcShowDaysTableMap' => 'airtime/map/CcShowDaysTableMap.php',
'CcShowDaysPeer' => 'airtime/CcShowDaysPeer.php',
'CcShowDays' => 'airtime/CcShowDays.php',
'CcShowDaysQuery' => 'airtime/CcShowDaysQuery.php',
'BaseCcShowDaysPeer' => 'airtime/om/BaseCcShowDaysPeer.php',
'BaseCcShowDays' => 'airtime/om/BaseCcShowDays.php',
'BaseCcShowDaysQuery' => 'airtime/om/BaseCcShowDaysQuery.php',
'CcShowHostsTableMap' => 'airtime/map/CcShowHostsTableMap.php',
'CcShowHostsPeer' => 'airtime/CcShowHostsPeer.php',
'CcShowHosts' => 'airtime/CcShowHosts.php',
'CcShowHostsQuery' => 'airtime/CcShowHostsQuery.php',
'BaseCcShowHostsPeer' => 'airtime/om/BaseCcShowHostsPeer.php',
'BaseCcShowHosts' => 'airtime/om/BaseCcShowHosts.php',
'BaseCcShowHostsQuery' => 'airtime/om/BaseCcShowHostsQuery.php',
'CcShowScheduleTableMap' => 'airtime/map/CcShowScheduleTableMap.php',
'CcShowSchedulePeer' => 'airtime/CcShowSchedulePeer.php',
'CcShowSchedule' => 'airtime/CcShowSchedule.php',
'CcShowScheduleQuery' => 'airtime/CcShowScheduleQuery.php',
'BaseCcShowSchedulePeer' => 'airtime/om/BaseCcShowSchedulePeer.php',
'BaseCcShowSchedule' => 'airtime/om/BaseCcShowSchedule.php',
'BaseCcShowScheduleQuery' => 'airtime/om/BaseCcShowScheduleQuery.php',
'CcPlaylistTableMap' => 'airtime/map/CcPlaylistTableMap.php',
'CcPlaylistPeer' => 'airtime/CcPlaylistPeer.php',
'CcPlaylist' => 'airtime/CcPlaylist.php',
'CcPlaylistQuery' => 'airtime/CcPlaylistQuery.php',
'BaseCcPlaylistPeer' => 'airtime/om/BaseCcPlaylistPeer.php',
'BaseCcPlaylist' => 'airtime/om/BaseCcPlaylist.php',
'BaseCcPlaylistQuery' => 'airtime/om/BaseCcPlaylistQuery.php',
'CcPlaylistcontentsTableMap' => 'airtime/map/CcPlaylistcontentsTableMap.php',
'CcPlaylistcontentsPeer' => 'airtime/CcPlaylistcontentsPeer.php',
'CcPlaylistcontents' => 'airtime/CcPlaylistcontents.php',
'CcPlaylistcontentsQuery' => 'airtime/CcPlaylistcontentsQuery.php',
'BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php',
'BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php',
'BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php',
'CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php',
'CcPrefPeer' => 'airtime/CcPrefPeer.php',
'CcPref' => 'airtime/CcPref.php',
'CcPrefQuery' => 'airtime/CcPrefQuery.php',
'BaseCcPrefPeer' => 'airtime/om/BaseCcPrefPeer.php',
'BaseCcPref' => 'airtime/om/BaseCcPref.php',
'BaseCcPrefQuery' => 'airtime/om/BaseCcPrefQuery.php',
'CcScheduleTableMap' => 'airtime/map/CcScheduleTableMap.php',
'CcSchedulePeer' => 'airtime/CcSchedulePeer.php',
'CcSchedule' => 'airtime/CcSchedule.php',
'CcScheduleQuery' => 'airtime/CcScheduleQuery.php',
'BaseCcSchedulePeer' => 'airtime/om/BaseCcSchedulePeer.php',
'BaseCcSchedule' => 'airtime/om/BaseCcSchedule.php',
'BaseCcScheduleQuery' => 'airtime/om/BaseCcScheduleQuery.php',
'CcSessTableMap' => 'airtime/map/CcSessTableMap.php',
'CcSessPeer' => 'airtime/CcSessPeer.php',
'CcSess' => 'airtime/CcSess.php',
'CcSessQuery' => 'airtime/CcSessQuery.php',
'BaseCcSessPeer' => 'airtime/om/BaseCcSessPeer.php',
'BaseCcSess' => 'airtime/om/BaseCcSess.php',
'BaseCcSessQuery' => 'airtime/om/BaseCcSessQuery.php',
'CcSmembTableMap' => 'airtime/map/CcSmembTableMap.php',
'CcSmembPeer' => 'airtime/CcSmembPeer.php',
'CcSmemb' => 'airtime/CcSmemb.php',
'CcSmembQuery' => 'airtime/CcSmembQuery.php',
'BaseCcSmembPeer' => 'airtime/om/BaseCcSmembPeer.php',
'BaseCcSmemb' => 'airtime/om/BaseCcSmemb.php',
'BaseCcSmembQuery' => 'airtime/om/BaseCcSmembQuery.php',
'CcSubjsTableMap' => 'airtime/map/CcSubjsTableMap.php',
'CcSubjsPeer' => 'airtime/CcSubjsPeer.php',
'CcSubjs' => 'airtime/CcSubjs.php',
'CcSubjsQuery' => 'airtime/CcSubjsQuery.php',
'BaseCcSubjsPeer' => 'airtime/om/BaseCcSubjsPeer.php',
'BaseCcSubjs' => 'airtime/om/BaseCcSubjs.php',
'BaseCcSubjsQuery' => 'airtime/om/BaseCcSubjsQuery.php',
'CcTransTableMap' => 'airtime/map/CcTransTableMap.php',
'CcTransPeer' => 'airtime/CcTransPeer.php',
'CcTrans' => 'airtime/CcTrans.php',
'CcTransQuery' => 'airtime/CcTransQuery.php',
'BaseCcTransPeer' => 'airtime/om/BaseCcTransPeer.php',
'BaseCcTrans' => 'airtime/om/BaseCcTrans.php',
'BaseCcTransQuery' => 'airtime/om/BaseCcTransQuery.php',
);

View file

@ -49,17 +49,11 @@ class ScheduleController extends Zend_Controller_Action
{
$start = $this->_getParam('start', null);
$end = $this->_getParam('end', null);
$weekday = $this->_getParam('weekday', null);
if(!is_null($weekday)) {
$weekday = array($weekday);
}
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type));
$this->view->events = $show->getFullCalendarEvents($start, $end, $weekday);
$this->view->events = $show->getFullCalendarEvents($start, $end);
}
public function addShowDialogAction()
@ -137,13 +131,12 @@ class ScheduleController extends Zend_Controller_Action
{
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
$showInstanceId = $this->_getParam('showInstanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type));
$overlap = $show->moveShow($showId, $deltaDay, $deltaMin);
$overlap = $show->moveShow($showInstanceId, $deltaDay, $deltaMin);
if(isset($overlap))
$this->view->overlap = $overlap;
@ -153,13 +146,12 @@ class ScheduleController extends Zend_Controller_Action
{
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
$showInstanceId = $this->_getParam('showInstanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type));
$overlap = $show->resizeShow($showId, $deltaDay, $deltaMin);
$overlap = $show->resizeShow($showInstanceId, $deltaDay, $deltaMin);
if(isset($overlap))
$this->view->overlap = $overlap;

View file

@ -3,9 +3,12 @@
class Application_Model_Preference
{
public static function SetValue($key, $value, $id){
public static function SetValue($key, $value){
global $CC_CONFIG, $CC_DBC;
$auth = Zend_Auth::getInstance();
$id = $auth->getIdentity()->id;
//Check if key already exists
$sql = "SELECT COUNT(*) FROM cc_pref"
." WHERE keystr = '$key'";
@ -57,10 +60,7 @@ class Application_Model_Preference
}
public static function SetHeadTitle($title, $view){
$auth = Zend_Auth::getInstance();
$id = $auth->getIdentity()->id;
Application_Model_Preference::SetValue("station_name", $title, $id);
Application_Model_Preference::SetValue("station_name", $title);
$defaultNamespace = new Zend_Session_Namespace('title_name');
$defaultNamespace->title = $title;
@ -70,5 +70,13 @@ class Application_Model_Preference
$view->headTitle(Application_Model_Preference::GetHeadTitle());
}
public static function SetShowsPopulatedUntil($timestamp) {
Application_Model_Preference::SetValue("shows_populated_until", $timestamp);
}
public static function GetShowsPopulatedUntil() {
return Application_Model_Preference::GetValue("shows_populated_until");
}
}

View file

@ -55,15 +55,23 @@ class Show {
$data['add_show_day_check'] = array($startDow);
}
/*
$overlap = $this->getShows($data['add_show_start_date'], $endDate, $data['add_show_day_check'], $data['add_show_start_time'], $endTime);
if(count($overlap) > 0) {
return $overlap;
}
*/
if($data['add_show_repeats']) {
$repeat_type = 0; //chnage this when supporting more than just a weekly show option.
}
else {
$repeat_type = -1;
}
$show = new CcShow();
$show->setDbName($data['add_show_name']);
$show->setDbRepeats($data['add_show_repeats']);
$show->setDbDescription($data['add_show_description']);
$show->setDbColor($data['add_show_color']);
$show->setDbBackgroundColor($data['add_show_background_color']);
@ -94,8 +102,9 @@ class Show {
$showDay->setDbFirstShow($start);
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($data['add_show_start_time']);
$showDay->setDbEndTime($endTime);
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbDay($day);
$showDay->setDbRepeatType($repeat_type);
$showDay->setDbShowId($showId);
$showDay->save();
}
@ -107,18 +116,14 @@ class Show {
$showHost->setDbHost($host);
$showHost->save();
}
$this->populateShowUntilLastGeneratedDate($showId);
}
public function moveShow($showId, $deltaDay, $deltaMin){
public function moveShow($showInstanceId, $deltaDay, $deltaMin){
global $CC_DBC;
$sql = "SELECT * FROM cc_show_days WHERE show_id = '{$showId}'";
$res = $CC_DBC->GetAll($sql);
$show = $res[0];
$start = $show["first_show"];
$end = $show["last_show"];
$days = array();
$showInstance = CcShowInstancesQuery::create()->findPK($showInstanceId);
$hours = $deltaMin/60;
if($hours > 0)
@ -128,50 +133,31 @@ class Show {
$mins = abs($deltaMin%60);
$sql = "SELECT time '{$show["start_time"]}' + interval '{$hours}:{$mins}'";
$s_time = $CC_DBC->GetOne($sql);
$starts = $showInstance->getDbStarts();
$ends = $showInstance->getDbEnds();
$sql = "SELECT time '{$show["end_time"]}' + interval '{$hours}:{$mins}'";
$e_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$new_starts = $CC_DBC->GetOne($sql);
foreach($res as $show) {
$days[] = $show["day"] + $deltaDay;
}
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$new_ends = $CC_DBC->GetOne($sql);
//need to check each specific day if times different then merge arrays.
$overlap = $this->getShows($start, $end, $days, $s_time, $e_time, array($showId));
$overlap = $this->getShows($new_starts, $new_ends);
if(count($overlap) > 0) {
return $overlap;
}
foreach($res as $row) {
$sql = "SELECT date '{$show["first_show"]}' + interval '{$deltaDay} day'";
$f_show = $CC_DBC->GetOne($sql);
//get a timestamp back only need a date.
$tmp = spliti(" ", $f_show);
$f_show = $tmp[0];
$show = CcShowDaysQuery::create()->findPK($row["id"]);
$show->setDbStartTime($s_time);
$show->setDbEndTime($e_time);
$show->setDbFirstShow($f_show);
$show->setDbDay($row['day'] + $deltaDay);
$show->save();
}
$showInstance
->setDbStarts($new_starts)
->setDbEnds($new_ends)
->save();
}
public function resizeShow($showId, $deltaDay, $deltaMin){
public function resizeShow($showInstanceId, $deltaDay, $deltaMin){
global $CC_DBC;
$sql = "SELECT * FROM cc_show_days WHERE show_id = '{$showId}'";
$res = $CC_DBC->GetAll($sql);
$show = $res[0];
$start = $show["first_show"];
$end = $show["last_show"];
$days = array();
$showInstance = CcShowInstancesQuery::create()->findPK($showInstanceId);
$hours = $deltaMin/60;
if($hours > 0)
@ -181,29 +167,34 @@ class Show {
$mins = abs($deltaMin%60);
$s_time = $show["start_time"];
$starts = $showInstance->getDbStarts();
$ends = $showInstance->getDbEnds();
$sql = "SELECT time '{$show["end_time"]}' + interval '{$hours}:{$mins}'";
$e_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$ends}' + interval '{$hours}:{$mins}'";
$new_ends = $CC_DBC->GetOne($sql);
foreach($res as $show) {
$days[] = $show["day"] + $deltaDay;
//only need to check overlap if show increased in size.
if(strtotime($new_ends) > strtotime($ends)) {
$overlap = $this->getShows($ends, $new_ends);
}
//need to check each specific day if times different then merge arrays.
$overlap = $this->getShows($start, $end, $days, $s_time, $e_time, array($showId));
if(count($overlap) > 0) {
return $overlap;
}
$showInstance
->setDbEnds($new_ends)
->save();
//needed if option is for all future shows.
/*
foreach($res as $row) {
$show = CcShowDaysQuery::create()->findPK($row["id"]);
$show->setDbStartTime($s_time);
$show->setDbEndTime($e_time);
$show->save();
}
*/
}
private function getNextPos($day) {
@ -467,162 +458,164 @@ class Show {
$show->delete();
}
}
public function getShows($start=NULL, $end=NULL, $days=NULL, $s_time=NULL, $e_time=NULL, $exclude_shows=NULL) {
public function getShows($start_timestamp, $end_timestamp) {
global $CC_DBC;
$sql;
$sql_gen = "SELECT cc_show_days.id AS day_id, name, repeats, description, color, background_color,
first_show, last_show, start_time, end_time, day, show_id
FROM (cc_show LEFT JOIN cc_show_days ON cc_show.id = cc_show_days.show_id)";
$sql = $sql_gen;
if(!is_null($start) && !is_null($end)) {
$sql_range = "(first_show < '{$start}' AND last_show IS NULL)
OR (first_show >= '{$start}' AND first_show < '{$end}')
OR (last_show >= '{$start}' AND last_show < '{$end}')
OR (first_show < '{$start}' AND last_show >= '{$end}')";
$sql = $sql_gen ." WHERE ". $sql_range;
}
if(!is_null($start) && is_null($end)) {
$sql_range = "(first_show <= '{$start}' AND last_show IS NULL)
OR (first_show <= '{$start}' AND last_show > '{$start}')
OR (first_show >= '{$start}')";
$sql = $sql_gen ." WHERE ". $sql_range;
}
if(!is_null($days)){
$sql_opt = array();
foreach ($days as $day) {
$sql_opt[] = "day = {$day}";
}
$sql_day = join(" OR ", $sql_opt);
$sql = $sql_gen ." WHERE ((". $sql_day .") AND (". $sql_range ."))";
}
if(!is_null($s_time) && !is_null($e_time)) {
$sql_time = "(start_time <= '{$s_time}' AND end_time >= '{$e_time}' AND start_time < end_time AND '{$s_time}' < '{$e_time}')
OR (start_time >= '{$s_time}' AND end_time <= '{$e_time}' AND start_time > end_time AND '{$s_time}' > '{$e_time}')
OR (start_time >= '{$s_time}' AND end_time <= '{$e_time}' AND start_time < end_time)
OR (start_time <= '{$s_time}' AND end_time >= '{$e_time}' AND start_time > end_time)
OR (start_time <= '{$s_time}' AND end_time <= '{$e_time}' AND start_time > end_time AND '{$s_time}' > '{$e_time}')
OR (start_time >= '{$s_time}' AND end_time >= '{$e_time}' AND start_time > end_time AND '{$s_time}' > '{$e_time}')
OR (end_time > '{$s_time}' AND end_time <= '{$e_time}')
OR (start_time >= '{$s_time}' AND start_time < '{$e_time}')";
$sql = $sql_gen ." WHERE ((". $sql_day .") AND (". $sql_range .") AND (". $sql_time ."))";
}
if(!is_null($exclude_shows)){
$sql_opt = array();
foreach ($exclude_shows as $showid) {
$sql_opt[] = "show_id = {$showid}";
}
$sql_showid = join(" OR ", $sql_opt);
$sql = $sql_gen ." WHERE ((". $sql_day .") AND NOT (". $sql_showid .") AND (". $sql_range .") AND (". $sql_time ."))";
}
$sql = "SELECT starts, ends, show_id, name, description, color, background_color, cc_show_instances.id AS instance_id
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
WHERE starts >= '{$start_timestamp}' AND starts <= '{$end_timestamp}'
OR ends > '{$start_timestamp}' AND ends <= '{$end_timestamp}'";
//echo $sql;
return $CC_DBC->GetAll($sql);
}
public function getFullCalendarEvents($start, $end, $weekday=NULL) {
//for a show with repeat_type == -1
private function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp) {
global $CC_DBC;
$shows = array();
$res = $this->getShows($start, $end, $weekday);
$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);
$newShow = new CcShowInstances();
$newShow->setDbShowId($show_id);
$newShow->setDbStarts($start);
$newShow->setDbEnds($end);
$newShow->save();
}
}
//for a show with repeat_type == 0
private function populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
global $CC_DBC;
if(isset($next_pop_date)) {
$next_date = $next_pop_date." ".$start_time;
}
else {
$next_date = $first_show." ".$start_time;
}
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);
$newShow = new CcShowInstances();
$newShow->setDbShowId($show_id);
$newShow->setDbStarts($start);
$newShow->setDbEnds($end);
$newShow->save();
$sql = "SELECT timestamp '{$start}' + interval '7 days'";
$next_date = $CC_DBC->GetOne($sql);
}
$nextInfo = explode(" ", $next_date);
$repeatInfo = CcShowDaysQuery::create()
->filterByDbShowId($show_id)
->filterByDbDay($day)
->findOne();
$repeatInfo->setDbNextPopDate($nextInfo[0])
->save();
}
private function populateShow($repeat_type, $show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
if($repeat_type == -1) {
$this->populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp);
}
else if($repeat_type == 0) {
$this->populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
}
}
//used to catch up a newly added show
private function populateShowUntilLastGeneratedDate($show_id) {
global $CC_DBC;
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
$res = $CC_DBC->GetAll($sql);
foreach($res as $row) {
$timeDiff = "SELECT date '{$start}' - date '{$row["first_show"]}' as diff";
$diff = $CC_DBC->GetOne($timeDiff);
if($diff > 0) {
$add = ($diff % 7 === 0) ? $diff : $diff + (7 - $diff % 7);
$new = "SELECT date '{$row["first_show"]}' + integer '{$add}'";
$newDate = $CC_DBC->GetOne($new);
}
else {
$newDate = $row["first_show"];
}
$new_epoch = strtotime($newDate);
$end_epoch = strtotime($end);
if(!is_null($row["last_show"])) {
$show_end_epoch = strtotime($row["last_show"]);
}
if(isset($show_end_epoch) && $show_end_epoch <= $new_epoch) {
continue;
}
$shows[] = $this->makeFullCalendarEvent($row, $newDate);
//add repeating events until the show end is reached or fullcalendar's end date is reached.
if($row["repeats"]) {
while(true) {
$diff = "SELECT date '{$newDate}' + integer '7'";
$repeatDate = $CC_DBC->GetOne($diff);
$repeat_epoch = strtotime($repeatDate);
//show has finite duration.
if (isset($show_end_epoch) && $repeat_epoch < $show_end_epoch && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
//case for non-ending shows.
else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
else {
break;
}
$newDate = $repeatDate;
$this->populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $showsPopUntil);
}
}
unset($show_end_epoch);
}
return $shows;
}
private function makeFullCalendarEvent($show, $date, $options=array()) {
public function populateShowsUntil($pop_timestamp, $end_timestamp) {
global $CC_DBC;
$start_ts = $date." ".$show["start_time"];
$end_ts = $date." ".$show["end_time"];
if($pop_timestamp != "") {
$sql = "SELECT * FROM cc_show_days
WHERE last_show IS NULL
OR first_show < '{$end_timestamp}' AND last_show > '{$pop_timestamp}'";
}
else {
$today_timestamp = date("Y-m-d");
$sql = "SELECT timestamp '{$start_ts}' > timestamp '{$end_ts}'";
$isNextDay = $CC_DBC->GetOne($sql);
if($isNextDay === 't') {
$sql = "SELECT date '{$date}' + interval '1 day {$show["end_time"]}'";
$end_ts = $CC_DBC->GetOne($sql);
$sql = "SELECT * FROM cc_show_days
WHERE last_show IS NULL
OR first_show < '{$end_timestamp}' AND last_show > '{$today_timestamp}'";
}
$res = $CC_DBC->GetAll($sql);
foreach($res as $row) {
$this->populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $end_timestamp);
}
}
public function getFullCalendarEvents($start, $end) {
$events = array();
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
if($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
$this->populateShowsUntil($showsPopUntil, $end);
Application_Model_Preference::SetShowsPopulatedUntil($end);
}
$shows = $this->getShows($start, $end);
foreach ($shows as $show) {
$events[] = $this->makeFullCalendarEvent($show);
}
return $events;
}
private function makeFullCalendarEvent($show, $options=array()) {
global $CC_DBC;
$event = array(
"id" => $show["show_id"],
"id" => $show["instance_id"],
"title" => $show["name"],
"start" => $start_ts,
"end" => $end_ts,
"start" => $show["starts"],
"end" => $show["ends"],
"allDay" => false,
"description" => $show["description"],
"color" => $show["color"],
"backgroundColor" => $show["background_color"]
"backgroundColor" => $show["background_color"],
"showId" => $show["show_id"]
);
foreach($options as $key=>$value) {
@ -630,14 +623,14 @@ class Show {
}
if($this->_user->isAdmin()) {
//$event["editable"] = true;
$event["editable"] = true;
}
if($this->_user->isHost($show["show_id"])) {
$event["isHost"] = true;
}
$percent = Schedule::getPercentScheduledInRange($start_ts, $end_ts);
$percent = Schedule::getPercentScheduledInRange($show["starts"], $show["ends"]);
$event["percent"] = $percent;
return $event;

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstances extends BaseCcShowInstances {
} // CcShowInstances

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstancesPeer extends BaseCcShowInstancesPeer {
} // CcShowInstancesPeer

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstancesQuery extends BaseCcShowInstancesQuery {
} // CcShowInstancesQuery

View file

@ -42,8 +42,10 @@ 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('END_TIME', 'DbEndTime', 'TIME', true, null, null);
$this->addColumn('DURATION', 'DbDuration', 'TIME', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
$this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null);
$this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null);
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
// validators
} // initialize()

View file

@ -0,0 +1,56 @@
<?php
/**
* This class defines the structure of the 'cc_show_instances' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.airtime.map
*/
class CcShowInstancesTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'airtime.map.CcShowInstancesTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_show_instances');
$this->setPhpName('CcShowInstances');
$this->setClassname('CcShowInstances');
$this->setPackage('airtime');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_show_instances_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null);
$this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null);
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcShowInstancesTableMap

View file

@ -40,7 +40,6 @@ class CcShowTableMap extends TableMap {
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, '');
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null);
$this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null);
@ -52,6 +51,7 @@ class CcShowTableMap extends TableMap {
*/
public function buildRelations()
{
$this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null);
$this->addRelation('CcShowDays', 'CcShowDays', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null);
$this->addRelation('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null);
$this->addRelation('CcShowSchedule', 'CcShowSchedule', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null);

View file

@ -37,12 +37,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/
protected $name;
/**
* The value for the repeats field.
* @var int
*/
protected $repeats;
/**
* The value for the description field.
* @var string
@ -61,6 +55,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/
protected $background_color;
/**
* @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects.
*/
protected $collCcShowInstancess;
/**
* @var array CcShowDays[] Collection to store aggregation of CcShowDays objects.
*/
@ -131,16 +130,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->name;
}
/**
* Get the [repeats] column value.
*
* @return int
*/
public function getDbRepeats()
{
return $this->repeats;
}
/**
* Get the [description] column value.
*
@ -211,26 +200,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this;
} // setDbName()
/**
* Set the value of [repeats] column.
*
* @param int $v new value
* @return CcShow The current object (for fluent API support)
*/
public function setDbRepeats($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->repeats !== $v) {
$this->repeats = $v;
$this->modifiedColumns[] = CcShowPeer::REPEATS;
}
return $this;
} // setDbRepeats()
/**
* Set the value of [description] column.
*
@ -329,10 +298,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->repeats = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
$this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->color = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->background_color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->description = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->color = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->background_color = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->resetModified();
$this->setNew(false);
@ -341,7 +309,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 6; // 6 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 5; // 5 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShow object", $e);
@ -403,6 +371,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
$this->collCcShowInstancess = null;
$this->collCcShowDayss = null;
$this->collCcShowHostss = null;
@ -542,6 +512,14 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
if ($this->collCcShowInstancess !== null) {
foreach ($this->collCcShowInstancess as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collCcShowDayss !== null) {
foreach ($this->collCcShowDayss as $referrerFK) {
if (!$referrerFK->isDeleted()) {
@ -637,6 +615,14 @@ abstract class BaseCcShow extends BaseObject implements Persistent
}
if ($this->collCcShowInstancess !== null) {
foreach ($this->collCcShowInstancess as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collCcShowDayss !== null) {
foreach ($this->collCcShowDayss as $referrerFK) {
if (!$referrerFK->validate($columns)) {
@ -701,15 +687,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->getDbName();
break;
case 2:
return $this->getDbRepeats();
break;
case 3:
return $this->getDbDescription();
break;
case 4:
case 3:
return $this->getDbColor();
break;
case 5:
case 4:
return $this->getDbBackgroundColor();
break;
default:
@ -737,10 +720,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$result = array(
$keys[0] => $this->getDbId(),
$keys[1] => $this->getDbName(),
$keys[2] => $this->getDbRepeats(),
$keys[3] => $this->getDbDescription(),
$keys[4] => $this->getDbColor(),
$keys[5] => $this->getDbBackgroundColor(),
$keys[2] => $this->getDbDescription(),
$keys[3] => $this->getDbColor(),
$keys[4] => $this->getDbBackgroundColor(),
);
return $result;
}
@ -779,15 +761,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->setDbName($value);
break;
case 2:
$this->setDbRepeats($value);
break;
case 3:
$this->setDbDescription($value);
break;
case 4:
case 3:
$this->setDbColor($value);
break;
case 5:
case 4:
$this->setDbBackgroundColor($value);
break;
} // switch()
@ -816,10 +795,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbRepeats($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbDescription($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbColor($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbBackgroundColor($arr[$keys[5]]);
if (array_key_exists($keys[2], $arr)) $this->setDbDescription($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbColor($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbBackgroundColor($arr[$keys[4]]);
}
/**
@ -833,7 +811,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowPeer::ID)) $criteria->add(CcShowPeer::ID, $this->id);
if ($this->isColumnModified(CcShowPeer::NAME)) $criteria->add(CcShowPeer::NAME, $this->name);
if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color);
if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color);
@ -899,7 +876,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDbName($this->name);
$copyObj->setDbRepeats($this->repeats);
$copyObj->setDbDescription($this->description);
$copyObj->setDbColor($this->color);
$copyObj->setDbBackgroundColor($this->background_color);
@ -909,6 +885,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
foreach ($this->getCcShowInstancess() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCcShowInstances($relObj->copy($deepCopy));
}
}
foreach ($this->getCcShowDayss() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCcShowDays($relObj->copy($deepCopy));
@ -972,6 +954,115 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return self::$peer;
}
/**
* Clears out the collCcShowInstancess collection
*
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
* @return void
* @see addCcShowInstancess()
*/
public function clearCcShowInstancess()
{
$this->collCcShowInstancess = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Initializes the collCcShowInstancess collection.
*
* By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess());
* however, you may wish to override this method in your stub class to provide setting appropriate
* to your application -- for example, setting the initial array to the values stored in database.
*
* @return void
*/
public function initCcShowInstancess()
{
$this->collCcShowInstancess = new PropelObjectCollection();
$this->collCcShowInstancess->setModel('CcShowInstances');
}
/**
* Gets an array of CcShowInstances objects which contain a foreign key that references this object.
*
* If the $criteria is not null, it is used to always fetch the results from the database.
* Otherwise the results are fetched from the database the first time, then cached.
* Next time the same method is called without $criteria, the cached collection is returned.
* If this CcShow is new, it will return
* an empty collection or the current collection; the criteria is ignored on a new object.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
* @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
* @throws PropelException
*/
public function getCcShowInstancess($criteria = null, PropelPDO $con = null)
{
if(null === $this->collCcShowInstancess || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowInstancess) {
// return empty collection
$this->initCcShowInstancess();
} else {
$collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria)
->filterByCcShow($this)
->find($con);
if (null !== $criteria) {
return $collCcShowInstancess;
}
$this->collCcShowInstancess = $collCcShowInstancess;
}
}
return $this->collCcShowInstancess;
}
/**
* Returns the number of related CcShowInstances objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param PropelPDO $con
* @return int Count of related CcShowInstances objects.
* @throws PropelException
*/
public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
if(null === $this->collCcShowInstancess || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowInstancess) {
return 0;
} else {
$query = CcShowInstancesQuery::create(null, $criteria);
if($distinct) {
$query->distinct();
}
return $query
->filterByCcShow($this)
->count($con);
}
} else {
return count($this->collCcShowInstancess);
}
}
/**
* Method called to associate a CcShowInstances object to this object
* through the CcShowInstances foreign key attribute.
*
* @param CcShowInstances $l CcShowInstances
* @return void
* @throws PropelException
*/
public function addCcShowInstances(CcShowInstances $l)
{
if ($this->collCcShowInstancess === null) {
$this->initCcShowInstancess();
}
if (!$this->collCcShowInstancess->contains($l)) { // only add it if the **same** object is not already associated
$this->collCcShowInstancess[]= $l;
$l->setCcShow($this);
}
}
/**
* Clears out the collCcShowDayss collection
*
@ -1331,7 +1422,6 @@ abstract class BaseCcShow extends BaseObject implements Persistent
{
$this->id = null;
$this->name = null;
$this->repeats = null;
$this->description = null;
$this->color = null;
$this->background_color = null;
@ -1356,6 +1446,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
if ($this->collCcShowInstancess) {
foreach ((array) $this->collCcShowInstancess as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCcShowDayss) {
foreach ((array) $this->collCcShowDayss as $o) {
$o->clearAllReferences($deep);
@ -1373,6 +1468,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
}
} // if ($deep)
$this->collCcShowInstancess = null;
$this->collCcShowDayss = null;
$this->collCcShowHostss = null;
$this->collCcShowSchedules = null;

View file

@ -49,10 +49,10 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
protected $start_time;
/**
* The value for the end_time field.
* The value for the duration field.
* @var string
*/
protected $end_time;
protected $duration;
/**
* The value for the day field.
@ -60,6 +60,18 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
*/
protected $day;
/**
* The value for the repeat_type field.
* @var int
*/
protected $repeat_type;
/**
* The value for the next_pop_date field.
* @var string
*/
protected $next_pop_date;
/**
* The value for the show_id field.
* @var int
@ -195,7 +207,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
}
/**
* Get the [optionally formatted] temporal [end_time] column value.
* Get the [optionally formatted] temporal [duration] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
@ -203,18 +215,18 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbEndTime($format = '%X')
public function getDbDuration($format = '%X')
{
if ($this->end_time === null) {
if ($this->duration === null) {
return null;
}
try {
$dt = new DateTime($this->end_time);
$dt = new DateTime($this->duration);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->end_time, true), $x);
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->duration, true), $x);
}
if ($format === null) {
@ -237,6 +249,49 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
return $this->day;
}
/**
* Get the [repeat_type] column value.
*
* @return int
*/
public function getDbRepeatType()
{
return $this->repeat_type;
}
/**
* Get the [optionally formatted] temporal [next_pop_date] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbNextPopDate($format = '%x')
{
if ($this->next_pop_date === null) {
return null;
}
try {
$dt = new DateTime($this->next_pop_date);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->next_pop_date, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [show_id] column value.
*
@ -415,13 +470,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
} // setDbStartTime()
/**
* Sets the value of [end_time] column to a normalized version of the date/time value specified.
* Sets the value of [duration] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcShowDays The current object (for fluent API support)
*/
public function setDbEndTime($v)
public function setDbDuration($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
@ -446,22 +501,22 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
}
}
if ( $this->end_time !== null || $dt !== null ) {
if ( $this->duration !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->end_time !== null && $tmpDt = new DateTime($this->end_time)) ? $tmpDt->format('H:i:s') : null;
$currNorm = ($this->duration !== null && $tmpDt = new DateTime($this->duration)) ? $tmpDt->format('H:i:s') : null;
$newNorm = ($dt !== null) ? $dt->format('H:i:s') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->end_time = ($dt ? $dt->format('H:i:s') : null);
$this->modifiedColumns[] = CcShowDaysPeer::END_TIME;
$this->duration = ($dt ? $dt->format('H:i:s') : null);
$this->modifiedColumns[] = CcShowDaysPeer::DURATION;
}
} // if either are not null
return $this;
} // setDbEndTime()
} // setDbDuration()
/**
* Set the value of [day] column.
@ -483,6 +538,75 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
return $this;
} // setDbDay()
/**
* Set the value of [repeat_type] column.
*
* @param int $v new value
* @return CcShowDays The current object (for fluent API support)
*/
public function setDbRepeatType($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->repeat_type !== $v) {
$this->repeat_type = $v;
$this->modifiedColumns[] = CcShowDaysPeer::REPEAT_TYPE;
}
return $this;
} // setDbRepeatType()
/**
* Sets the value of [next_pop_date] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcShowDays The current object (for fluent API support)
*/
public function setDbNextPopDate($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->next_pop_date !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->next_pop_date !== null && $tmpDt = new DateTime($this->next_pop_date)) ? $tmpDt->format('Y-m-d') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->next_pop_date = ($dt ? $dt->format('Y-m-d') : null);
$this->modifiedColumns[] = CcShowDaysPeer::NEXT_POP_DATE;
}
} // if either are not null
return $this;
} // setDbNextPopDate()
/**
* Set the value of [show_id] column.
*
@ -543,9 +667,11 @@ 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->end_time = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->duration = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->day = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->show_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : 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->resetModified();
$this->setNew(false);
@ -554,7 +680,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 7; // 7 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 9; // 9 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowDays object", $e);
@ -894,12 +1020,18 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
return $this->getDbStartTime();
break;
case 4:
return $this->getDbEndTime();
return $this->getDbDuration();
break;
case 5:
return $this->getDbDay();
break;
case 6:
return $this->getDbRepeatType();
break;
case 7:
return $this->getDbNextPopDate();
break;
case 8:
return $this->getDbShowId();
break;
default:
@ -930,9 +1062,11 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$keys[1] => $this->getDbFirstShow(),
$keys[2] => $this->getDbLastShow(),
$keys[3] => $this->getDbStartTime(),
$keys[4] => $this->getDbEndTime(),
$keys[4] => $this->getDbDuration(),
$keys[5] => $this->getDbDay(),
$keys[6] => $this->getDbShowId(),
$keys[6] => $this->getDbRepeatType(),
$keys[7] => $this->getDbNextPopDate(),
$keys[8] => $this->getDbShowId(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -982,12 +1116,18 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->setDbStartTime($value);
break;
case 4:
$this->setDbEndTime($value);
$this->setDbDuration($value);
break;
case 5:
$this->setDbDay($value);
break;
case 6:
$this->setDbRepeatType($value);
break;
case 7:
$this->setDbNextPopDate($value);
break;
case 8:
$this->setDbShowId($value);
break;
} // switch()
@ -1018,9 +1158,11 @@ 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->setDbEndTime($arr[$keys[4]]);
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->setDbShowId($arr[$keys[6]]);
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]]);
}
/**
@ -1036,8 +1178,10 @@ 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::END_TIME)) $criteria->add(CcShowDaysPeer::END_TIME, $this->end_time);
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);
if ($this->isColumnModified(CcShowDaysPeer::NEXT_POP_DATE)) $criteria->add(CcShowDaysPeer::NEXT_POP_DATE, $this->next_pop_date);
if ($this->isColumnModified(CcShowDaysPeer::SHOW_ID)) $criteria->add(CcShowDaysPeer::SHOW_ID, $this->show_id);
return $criteria;
@ -1103,8 +1247,10 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$copyObj->setDbFirstShow($this->first_show);
$copyObj->setDbLastShow($this->last_show);
$copyObj->setDbStartTime($this->start_time);
$copyObj->setDbEndTime($this->end_time);
$copyObj->setDbDuration($this->duration);
$copyObj->setDbDay($this->day);
$copyObj->setDbRepeatType($this->repeat_type);
$copyObj->setDbNextPopDate($this->next_pop_date);
$copyObj->setDbShowId($this->show_id);
$copyObj->setNew(true);
@ -1207,8 +1353,10 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent
$this->first_show = null;
$this->last_show = null;
$this->start_time = null;
$this->end_time = null;
$this->duration = null;
$this->day = null;
$this->repeat_type = null;
$this->next_pop_date = null;
$this->show_id = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowDaysPeer {
const TM_CLASS = 'CcShowDaysTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 7;
const NUM_COLUMNS = 9;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -43,12 +43,18 @@ abstract class BaseCcShowDaysPeer {
/** the column name for the START_TIME field */
const START_TIME = 'cc_show_days.START_TIME';
/** the column name for the END_TIME field */
const END_TIME = 'cc_show_days.END_TIME';
/** the column name for the DURATION field */
const DURATION = 'cc_show_days.DURATION';
/** the column name for the DAY field */
const DAY = 'cc_show_days.DAY';
/** the column name for the REPEAT_TYPE field */
const REPEAT_TYPE = 'cc_show_days.REPEAT_TYPE';
/** the column name for the NEXT_POP_DATE field */
const NEXT_POP_DATE = 'cc_show_days.NEXT_POP_DATE';
/** the column name for the SHOW_ID field */
const SHOW_ID = 'cc_show_days.SHOW_ID';
@ -68,12 +74,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', 'DbEndTime', 'DbDay', 'DbShowId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbDay', 'dbShowId', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::DAY, self::SHOW_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'DAY', 'SHOW_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'end_time', 'day', 'show_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', ),
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, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@ -83,12 +89,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, 'DbEndTime' => 4, 'DbDay' => 5, 'DbShowId' => 6, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbEndTime' => 4, 'dbDay' => 5, 'dbShowId' => 6, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::END_TIME => 4, self::DAY => 5, self::SHOW_ID => 6, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'END_TIME' => 4, 'DAY' => 5, 'SHOW_ID' => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'end_time' => 4, 'day' => 5, 'show_id' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbDuration' => 4, 'DbDay' => 5, 'DbRepeatType' => 6, 'DbNextPopDate' => 7, 'DbShowId' => 8, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbDuration' => 4, 'dbDay' => 5, 'dbRepeatType' => 6, 'dbNextPopDate' => 7, 'dbShowId' => 8, ),
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, ),
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, ),
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, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@ -164,16 +170,20 @@ abstract class BaseCcShowDaysPeer {
$criteria->addSelectColumn(CcShowDaysPeer::FIRST_SHOW);
$criteria->addSelectColumn(CcShowDaysPeer::LAST_SHOW);
$criteria->addSelectColumn(CcShowDaysPeer::START_TIME);
$criteria->addSelectColumn(CcShowDaysPeer::END_TIME);
$criteria->addSelectColumn(CcShowDaysPeer::DURATION);
$criteria->addSelectColumn(CcShowDaysPeer::DAY);
$criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE);
$criteria->addSelectColumn(CcShowDaysPeer::NEXT_POP_DATE);
$criteria->addSelectColumn(CcShowDaysPeer::SHOW_ID);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.FIRST_SHOW');
$criteria->addSelectColumn($alias . '.LAST_SHOW');
$criteria->addSelectColumn($alias . '.START_TIME');
$criteria->addSelectColumn($alias . '.END_TIME');
$criteria->addSelectColumn($alias . '.DURATION');
$criteria->addSelectColumn($alias . '.DAY');
$criteria->addSelectColumn($alias . '.REPEAT_TYPE');
$criteria->addSelectColumn($alias . '.NEXT_POP_DATE');
$criteria->addSelectColumn($alias . '.SHOW_ID');
}
}

View file

@ -10,16 +10,20 @@
* @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 orderByDbEndTime($order = Criteria::ASC) Order by the end_time 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
* @method CcShowDaysQuery orderByDbNextPopDate($order = Criteria::ASC) Order by the next_pop_date column
* @method CcShowDaysQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
*
* @method CcShowDaysQuery groupByDbId() Group by the id column
* @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 groupByDbEndTime() Group by the end_time 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
* @method CcShowDaysQuery groupByDbNextPopDate() Group by the next_pop_date column
* @method CcShowDaysQuery groupByDbShowId() Group by the show_id column
*
* @method CcShowDaysQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
@ -37,16 +41,20 @@
* @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 findOneByDbEndTime(string $end_time) Return the first CcShowDays filtered by the end_time 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
* @method CcShowDays findOneByDbNextPopDate(string $next_pop_date) Return the first CcShowDays filtered by the next_pop_date column
* @method CcShowDays findOneByDbShowId(int $show_id) Return the first CcShowDays filtered by the show_id column
*
* @method array findByDbId(int $id) Return CcShowDays objects filtered by the id column
* @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 findByDbEndTime(string $end_time) Return CcShowDays objects filtered by the end_time 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
* @method array findByDbNextPopDate(string $next_pop_date) Return CcShowDays objects filtered by the next_pop_date column
* @method array findByDbShowId(int $show_id) Return CcShowDays objects filtered by the show_id column
*
* @package propel.generator.airtime.om
@ -268,24 +276,24 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria
}
/**
* Filter the query on the end_time column
* Filter the query on the duration column
*
* @param string|array $dbEndTime The value to use as filter.
* @param string|array $dbDuration The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowDaysQuery The current query, for fluid interface
*/
public function filterByDbEndTime($dbEndTime = null, $comparison = null)
public function filterByDbDuration($dbDuration = null, $comparison = null)
{
if (is_array($dbEndTime)) {
if (is_array($dbDuration)) {
$useMinMax = false;
if (isset($dbEndTime['min'])) {
$this->addUsingAlias(CcShowDaysPeer::END_TIME, $dbEndTime['min'], Criteria::GREATER_EQUAL);
if (isset($dbDuration['min'])) {
$this->addUsingAlias(CcShowDaysPeer::DURATION, $dbDuration['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbEndTime['max'])) {
$this->addUsingAlias(CcShowDaysPeer::END_TIME, $dbEndTime['max'], Criteria::LESS_EQUAL);
if (isset($dbDuration['max'])) {
$this->addUsingAlias(CcShowDaysPeer::DURATION, $dbDuration['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@ -295,7 +303,7 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowDaysPeer::END_TIME, $dbEndTime, $comparison);
return $this->addUsingAlias(CcShowDaysPeer::DURATION, $dbDuration, $comparison);
}
/**
@ -329,6 +337,68 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria
return $this->addUsingAlias(CcShowDaysPeer::DAY, $dbDay, $comparison);
}
/**
* Filter the query on the repeat_type column
*
* @param int|array $dbRepeatType The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowDaysQuery The current query, for fluid interface
*/
public function filterByDbRepeatType($dbRepeatType = null, $comparison = null)
{
if (is_array($dbRepeatType)) {
$useMinMax = false;
if (isset($dbRepeatType['min'])) {
$this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbRepeatType['max'])) {
$this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType, $comparison);
}
/**
* Filter the query on the next_pop_date column
*
* @param string|array $dbNextPopDate The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowDaysQuery The current query, for fluid interface
*/
public function filterByDbNextPopDate($dbNextPopDate = null, $comparison = null)
{
if (is_array($dbNextPopDate)) {
$useMinMax = false;
if (isset($dbNextPopDate['min'])) {
$this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbNextPopDate['max'])) {
$this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate, $comparison);
}
/**
* Filter the query on the show_id column
*

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,983 @@
<?php
/**
* Base static class for performing query and update operations on the 'cc_show_instances' table.
*
*
*
* @package propel.generator.airtime.om
*/
abstract class BaseCcShowInstancesPeer {
/** the default database name for this class */
const DATABASE_NAME = 'airtime';
/** the table name for this class */
const TABLE_NAME = 'cc_show_instances';
/** the related Propel class for this table */
const OM_CLASS = 'CcShowInstances';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'airtime.CcShowInstances';
/** the related TableMap class for this table */
const TM_CLASS = 'CcShowInstancesTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 4;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'cc_show_instances.ID';
/** the column name for the STARTS field */
const STARTS = 'cc_show_instances.STARTS';
/** the column name for the ENDS field */
const ENDS = 'cc_show_instances.ENDS';
/** the column name for the SHOW_ID field */
const SHOW_ID = 'cc_show_instances.SHOW_ID';
/**
* An identiy map to hold any loaded instances of CcShowInstances objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
* queries.
* @var array CcShowInstances[]
*/
public static $instances = array();
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
* @throws PropelException - if the specified name could not be found in the fieldname mappings.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CcShowInstancesPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CcShowInstancesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CcShowInstancesPeer::ID);
$criteria->addSelectColumn(CcShowInstancesPeer::STARTS);
$criteria->addSelectColumn(CcShowInstancesPeer::ENDS);
$criteria->addSelectColumn(CcShowInstancesPeer::SHOW_ID);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.STARTS');
$criteria->addSelectColumn($alias . '.ENDS');
$criteria->addSelectColumn($alias . '.SHOW_ID');
}
}
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
{
// we may modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcShowInstancesPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// BasePeer returns a PDOStatement
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param PropelPDO $con
* @return CcShowInstances
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CcShowInstancesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
return CcShowInstancesPeer::populateObjects(CcShowInstancesPeer::doSelectStmt($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
*
* Use this method directly if you want to work with an executed statement durirectly (for example
* to perform your own object hydration).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con The connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return PDOStatement The executed PDOStatement object.
* @see BasePeer::doSelect()
*/
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
if (!$criteria->hasSelectClause()) {
$criteria = clone $criteria;
CcShowInstancesPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a PDOStatement
return BasePeer::doSelect($criteria, $con);
}
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param CcShowInstances $value A CcShowInstances object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(CcShowInstances $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getDbId();
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A CcShowInstances object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && $value !== null) {
if (is_object($value) && $value instanceof CcShowInstances) {
$key = (string) $value->getDbId();
} elseif (is_scalar($value)) {
// assume we've been passed a primary key
$key = (string) $value;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcShowInstances object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
throw $e;
}
unset(self::$instances[$key]);
}
} // removeInstanceFromPool()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param string $key The key (@see getPrimaryKeyHash()) for this instance.
* @return CcShowInstances Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
* @see getPrimaryKeyHash()
*/
public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(self::$instances[$key])) {
return self::$instances[$key];
}
}
return null; // just to be explicit
}
/**
* Clear the instance pool.
*
* @return void
*/
public static function clearInstancePool()
{
self::$instances = array();
}
/**
* Method to invalidate the instance pool of all tables related to cc_show_instances
* by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return string A string version of PK or NULL if the components of primary key in result array are all null.
*/
public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $startcol = 0)
{
return (int) $row[$startcol];
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(PDOStatement $stmt)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = CcShowInstancesPeer::getOMClass(false);
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj = CcShowInstancesPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CcShowInstancesPeer::addInstanceToPool($obj, $key);
} // if key exists
}
$stmt->closeCursor();
return $results;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CcShowInstances object, last column rank)
*/
public static function populateObject($row, $startcol = 0)
{
$key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol);
if (null !== ($obj = CcShowInstancesPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $startcol, true); // rehydrate
$col = $startcol + CcShowInstancesPeer::NUM_COLUMNS;
} else {
$cls = CcShowInstancesPeer::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $startcol);
CcShowInstancesPeer::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* Returns the number of rows matching criteria, joining the related CcShow table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinCcShow(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcShowInstancesPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcShowInstances objects pre-filled with their CcShow objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcShowInstances objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinCcShow(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcShowInstancesPeer::addSelectColumns($criteria);
$startcol = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS);
CcShowPeer::addSelectColumns($criteria);
$criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcShowInstancesPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcShowInstancesPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
$key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
$obj2 = CcShowPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcShowPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
CcShowPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
// Add the $obj1 (CcShowInstances) to $obj2 (CcShow)
$obj2->addCcShowInstances($obj1);
} // if joined row was not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcShowInstancesPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcShowInstances objects pre-filled with all related objects.
*
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcShowInstances objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcShowInstancesPeer::addSelectColumns($criteria);
$startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS);
CcShowPeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcShowInstancesPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcShowInstancesPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
// Add objects for joined CcShow rows
$key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
$obj2 = CcShowPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcShowPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
CcShowPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
// Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow)
$obj2->addCcShowInstances($obj1);
} // if joined row not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this peer class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseCcShowInstancesPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseCcShowInstancesPeer::TABLE_NAME))
{
$dbMap->addTableObject(new CcShowInstancesTableMap());
}
}
/**
* The class that the Peer will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CcShowInstancesPeer::CLASS_DEFAULT : CcShowInstancesPeer::OM_CLASS;
}
/**
* Method perform an INSERT on the database, given a CcShowInstances or Criteria object.
*
* @param mixed $values Criteria or CcShowInstances object containing data that is used to create the INSERT statement.
* @param PropelPDO $con the PropelPDO connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CcShowInstances object
}
if ($criteria->containsKey(CcShowInstancesPeer::ID) && $criteria->keyContainsValue(CcShowInstancesPeer::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowInstancesPeer::ID.')');
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CcShowInstances or Criteria object.
*
* @param mixed $values Criteria or CcShowInstances object containing data that is used to create the UPDATE statement.
* @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CcShowInstancesPeer::ID);
$value = $criteria->remove(CcShowInstancesPeer::ID);
if ($value) {
$selectCriteria->add(CcShowInstancesPeer::ID, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME);
}
} else { // $values is CcShowInstances object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the cc_show_instances table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(CcShowInstancesPeer::TABLE_NAME, $con, CcShowInstancesPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CcShowInstancesPeer::clearInstancePool();
CcShowInstancesPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CcShowInstances or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CcShowInstances object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
CcShowInstancesPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CcShowInstances) { // it's a model object
// invalidate the cache for this single object
CcShowInstancesPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CcShowInstancesPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
CcShowInstancesPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
CcShowInstancesPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Validates all modified columns of given CcShowInstances object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CcShowInstances $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CcShowInstances $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CcShowInstancesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CcShowInstancesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(CcShowInstancesPeer::DATABASE_NAME, CcShowInstancesPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param int $pk the primary key.
* @param PropelPDO $con the connection to use
* @return CcShowInstances
*/
public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = CcShowInstancesPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME);
$criteria->add(CcShowInstancesPeer::ID, $pk);
$v = CcShowInstancesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param PropelPDO $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME);
$criteria->add(CcShowInstancesPeer::ID, $pks, Criteria::IN);
$objs = CcShowInstancesPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCcShowInstancesPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseCcShowInstancesPeer::buildTableMap();

View file

@ -0,0 +1,338 @@
<?php
/**
* Base class that represents a query for the 'cc_show_instances' table.
*
*
*
* @method CcShowInstancesQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcShowInstancesQuery orderByDbStarts($order = Criteria::ASC) Order by the starts column
* @method CcShowInstancesQuery orderByDbEnds($order = Criteria::ASC) Order by the ends column
* @method CcShowInstancesQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
*
* @method CcShowInstancesQuery groupByDbId() Group by the id column
* @method CcShowInstancesQuery groupByDbStarts() Group by the starts column
* @method CcShowInstancesQuery groupByDbEnds() Group by the ends column
* @method CcShowInstancesQuery groupByDbShowId() Group by the show_id column
*
* @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowInstancesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CcShowInstancesQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CcShowInstancesQuery leftJoinCcShow($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShow relation
* @method CcShowInstancesQuery rightJoinCcShow($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShow relation
* @method CcShowInstancesQuery innerJoinCcShow($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShow relation
*
* @method CcShowInstances findOne(PropelPDO $con = null) Return the first CcShowInstances matching the query
* @method CcShowInstances findOneOrCreate(PropelPDO $con = null) Return the first CcShowInstances matching the query, or a new CcShowInstances object populated from the query conditions when no match is found
*
* @method CcShowInstances findOneByDbId(int $id) Return the first CcShowInstances filtered by the id column
* @method CcShowInstances findOneByDbStarts(string $starts) Return the first CcShowInstances filtered by the starts column
* @method CcShowInstances findOneByDbEnds(string $ends) Return the first CcShowInstances filtered by the ends column
* @method CcShowInstances findOneByDbShowId(int $show_id) Return the first CcShowInstances filtered by the show_id column
*
* @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column
* @method array findByDbStarts(string $starts) Return CcShowInstances objects filtered by the starts column
* @method array findByDbEnds(string $ends) Return CcShowInstances objects filtered by the ends column
* @method array findByDbShowId(int $show_id) Return CcShowInstances objects filtered by the show_id column
*
* @package propel.generator.airtime.om
*/
abstract class BaseCcShowInstancesQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseCcShowInstancesQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'airtime', $modelName = 'CcShowInstances', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new CcShowInstancesQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return CcShowInstancesQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CcShowInstancesQuery) {
return $criteria;
}
$query = new CcShowInstancesQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key
* Use instance pooling to avoid a database query if the object exists
* <code>
* $obj = $c->findPk(12, $con);
* </code>
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con an optional connection object
*
* @return CcShowInstances|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ((null !== ($obj = CcShowInstancesPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
// the object is alredy in the instance pool
return $obj;
} else {
// the object has not been requested yet, or the formatter is not an object formatter
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->getSelectStatement($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
}
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param PropelPDO $con an optional connection object
*
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
$criteria = $this->isKeepQuery() ? clone $this : $this;
return $this
->filterByPrimaryKeys($keys)
->find($con);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CcShowInstancesPeer::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CcShowInstancesPeer::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* @param int|array $dbId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbId($dbId = null, $comparison = null)
{
if (is_array($dbId) && null === $comparison) {
$comparison = Criteria::IN;
}
return $this->addUsingAlias(CcShowInstancesPeer::ID, $dbId, $comparison);
}
/**
* Filter the query on the starts column
*
* @param string|array $dbStarts The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbStarts($dbStarts = null, $comparison = null)
{
if (is_array($dbStarts)) {
$useMinMax = false;
if (isset($dbStarts['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbStarts['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts, $comparison);
}
/**
* Filter the query on the ends column
*
* @param string|array $dbEnds The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbEnds($dbEnds = null, $comparison = null)
{
if (is_array($dbEnds)) {
$useMinMax = false;
if (isset($dbEnds['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbEnds['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds, $comparison);
}
/**
* Filter the query on the show_id column
*
* @param int|array $dbShowId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbShowId($dbShowId = null, $comparison = null)
{
if (is_array($dbShowId)) {
$useMinMax = false;
if (isset($dbShowId['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbShowId['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId, $comparison);
}
/**
* Filter the query by a related CcShow object
*
* @param CcShow $ccShow the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByCcShow($ccShow, $comparison = null)
{
return $this
->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $ccShow->getDbId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcShow relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcShow');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CcShow');
}
return $this;
}
/**
* Use the CcShow relation CcShow object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcShowQuery A secondary query class using the current class as primary query
*/
public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCcShow($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery');
}
/**
* Exclude object from result
*
* @param CcShowInstances $ccShowInstances Object to remove from the list of results
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function prune($ccShowInstances = null)
{
if ($ccShowInstances) {
$this->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbId(), Criteria::NOT_EQUAL);
}
return $this;
}
} // BaseCcShowInstancesQuery

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
const TM_CLASS = 'CcShowTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 6;
const NUM_COLUMNS = 5;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -37,9 +37,6 @@ abstract class BaseCcShowPeer {
/** the column name for the NAME field */
const NAME = 'cc_show.NAME';
/** the column name for the REPEATS field */
const REPEATS = 'cc_show.REPEATS';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_show.DESCRIPTION';
@ -65,12 +62,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbRepeats', 'DbDescription', 'DbColor', 'DbBackgroundColor', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbRepeats', 'dbDescription', 'dbColor', 'dbBackgroundColor', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::REPEATS, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'REPEATS', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'repeats', 'description', 'color', 'background_color', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbDescription', 'DbColor', 'DbBackgroundColor', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbDescription', 'dbColor', 'dbBackgroundColor', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', 'color', 'background_color', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
@ -80,12 +77,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbRepeats' => 2, 'DbDescription' => 3, 'DbColor' => 4, 'DbBackgroundColor' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbRepeats' => 2, 'dbDescription' => 3, 'dbColor' => 4, 'dbBackgroundColor' => 5, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::REPEATS => 2, self::DESCRIPTION => 3, self::COLOR => 4, self::BACKGROUND_COLOR => 5, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'REPEATS' => 2, 'DESCRIPTION' => 3, 'COLOR' => 4, 'BACKGROUND_COLOR' => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'repeats' => 2, 'description' => 3, 'color' => 4, 'background_color' => 5, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbDescription' => 2, 'DbColor' => 3, 'DbBackgroundColor' => 4, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbDescription' => 2, 'dbColor' => 3, 'dbBackgroundColor' => 4, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::DESCRIPTION => 2, self::COLOR => 3, self::BACKGROUND_COLOR => 4, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'DESCRIPTION' => 2, 'COLOR' => 3, 'BACKGROUND_COLOR' => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, 'color' => 3, 'background_color' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
@ -159,14 +156,12 @@ abstract class BaseCcShowPeer {
if (null === $alias) {
$criteria->addSelectColumn(CcShowPeer::ID);
$criteria->addSelectColumn(CcShowPeer::NAME);
$criteria->addSelectColumn(CcShowPeer::REPEATS);
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
$criteria->addSelectColumn(CcShowPeer::COLOR);
$criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
$criteria->addSelectColumn($alias . '.REPEATS');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.COLOR');
$criteria->addSelectColumn($alias . '.BACKGROUND_COLOR');
@ -363,6 +358,9 @@ abstract class BaseCcShowPeer {
*/
public static function clearRelatedInstancePool()
{
// Invalidate objects in CcShowInstancesPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcShowInstancesPeer::clearInstancePool();
// Invalidate objects in CcShowDaysPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcShowDaysPeer::clearInstancePool();

View file

@ -8,14 +8,12 @@
*
* @method CcShowQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcShowQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcShowQuery orderByDbColor($order = Criteria::ASC) Order by the color column
* @method CcShowQuery orderByDbBackgroundColor($order = Criteria::ASC) Order by the background_color column
*
* @method CcShowQuery groupByDbId() Group by the id column
* @method CcShowQuery groupByDbName() Group by the name column
* @method CcShowQuery groupByDbRepeats() Group by the repeats column
* @method CcShowQuery groupByDbDescription() Group by the description column
* @method CcShowQuery groupByDbColor() Group by the color column
* @method CcShowQuery groupByDbBackgroundColor() Group by the background_color column
@ -24,6 +22,10 @@
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CcShowQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CcShowQuery leftJoinCcShowInstances($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowInstances relation
* @method CcShowQuery rightJoinCcShowInstances($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowInstances relation
* @method CcShowQuery innerJoinCcShowInstances($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowInstances relation
*
* @method CcShowQuery leftJoinCcShowDays($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowDays relation
* @method CcShowQuery rightJoinCcShowDays($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowDays relation
* @method CcShowQuery innerJoinCcShowDays($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowDays relation
@ -41,14 +43,12 @@
*
* @method CcShow findOneByDbId(int $id) Return the first CcShow filtered by the id column
* @method CcShow findOneByDbName(string $name) Return the first CcShow filtered by the name column
* @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
* @method CcShow findOneByDbColor(string $color) Return the first CcShow filtered by the color column
* @method CcShow findOneByDbBackgroundColor(string $background_color) Return the first CcShow filtered by the background_color column
*
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
* @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
* @method array findByDbColor(string $color) Return CcShow objects filtered by the color column
* @method array findByDbBackgroundColor(string $background_color) Return CcShow objects filtered by the background_color column
@ -200,37 +200,6 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::NAME, $dbName, $comparison);
}
/**
* Filter the query on the repeats column
*
* @param int|array $dbRepeats The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowQuery The current query, for fluid interface
*/
public function filterByDbRepeats($dbRepeats = null, $comparison = null)
{
if (is_array($dbRepeats)) {
$useMinMax = false;
if (isset($dbRepeats['min'])) {
$this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbRepeats['max'])) {
$this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats, $comparison);
}
/**
* Filter the query on the description column
*
@ -297,6 +266,70 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::BACKGROUND_COLOR, $dbBackgroundColor, $comparison);
}
/**
* Filter the query by a related CcShowInstances object
*
* @param CcShowInstances $ccShowInstances the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowQuery The current query, for fluid interface
*/
public function filterByCcShowInstances($ccShowInstances, $comparison = null)
{
return $this
->addUsingAlias(CcShowPeer::ID, $ccShowInstances->getDbShowId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcShowInstances relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcShowQuery The current query, for fluid interface
*/
public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcShowInstances');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CcShowInstances');
}
return $this;
}
/**
* Use the CcShowInstances relation CcShowInstances object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcShowInstancesQuery A secondary query class using the current class as primary query
*/
public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCcShowInstances($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery');
}
/**
* Filter the query by a related CcShowDays object
*

View file

@ -124,18 +124,28 @@
<table name="cc_show" phpName="CcShow">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="name" phpName="DbName" type="VARCHAR" size="255" required="true" defaultValue=""/>
<column name="repeats" phpName="DbRepeats" type="TINYINT" required="true"/>
<column name="description" phpName="DbDescription" type="VARCHAR" size="512" required="false"/>
<column name="color" phpName="DbColor" type="VARCHAR" size="6" required="false"/>
<column name="background_color" phpName="DbBackgroundColor" type="VARCHAR" size="6" required="false"/>
</table>
<table name="cc_show_instances" phpName="CcShowInstances">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="starts" phpName="DbStarts" type="TIMESTAMP" required="true"/>
<column name="ends" phpName="DbEnds" type="TIMESTAMP" required="true"/>
<column name="show_id" phpName="DbShowId" type="INTEGER" required="true"/>
<foreign-key foreignTable="cc_show" name="cc_show_fkey" onDelete="CASCADE">
<reference local="show_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_show_days" phpName="CcShowDays">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<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="end_time" phpName="DbEndTime" type="TIME" required="true"/>
<column name="duration" phpName="DbDuration" type="TIME" required="true"/>
<column name="day" phpName="DbDay" type="TINYINT" required="true"/>
<column name="repeat_type" phpName="DbRepeatType" type="TINYINT" required="true"/>
<column name="next_pop_date" phpName="DbNextPopDate" type="DATE" required="false"/>
<column name="show_id" phpName="DbShowId" type="INTEGER" required="true"/>
<foreign-key foreignTable="cc_show" name="cc_show_fkey" onDelete="CASCADE">
<reference local="show_id" foreign="id"/>

View file

@ -162,7 +162,6 @@ CREATE TABLE "cc_show"
(
"id" serial NOT NULL,
"name" VARCHAR(255) default '' NOT NULL,
"repeats" INT2 NOT NULL,
"description" VARCHAR(512),
"color" VARCHAR(6),
"background_color" VARCHAR(6),
@ -172,6 +171,26 @@ CREATE TABLE "cc_show"
COMMENT ON TABLE "cc_show" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_show_instances
-----------------------------------------------------------------------------
DROP TABLE "cc_show_instances" CASCADE;
CREATE TABLE "cc_show_instances"
(
"id" serial NOT NULL,
"starts" TIMESTAMP NOT NULL,
"ends" TIMESTAMP NOT NULL,
"show_id" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
COMMENT ON TABLE "cc_show_instances" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_show_days
@ -186,8 +205,10 @@ CREATE TABLE "cc_show_days"
"first_show" DATE NOT NULL,
"last_show" DATE,
"start_time" TIME NOT NULL,
"end_time" TIME NOT NULL,
"duration" TIME NOT NULL,
"day" INT2 NOT NULL,
"repeat_type" INT2 NOT NULL,
"next_pop_date" DATE,
"show_id" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
@ -463,6 +484,8 @@ ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_editedby_fkey" FOREIGN KEY ("edi
ALTER TABLE "cc_perms" ADD CONSTRAINT "cc_perms_subj_fkey" FOREIGN KEY ("subj") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_show_days" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE;

View file

@ -104,7 +104,7 @@ function eventAfterRender( event, element, view ) {
$(element)
.jjmenu("rightClick",
[{get:"/Schedule/make-context-menu/format/json/id/#id#/start/#start#/end/#end#"}],
{id: event.id, start: getStartTS, end: getEndTS},
{id: event.showId, start: getStartTS, end: getEndTS},
{xposition: "mouse", yposition: "mouse"});
/*
@ -134,15 +134,10 @@ function eventMouseout(event, jsEvent, view) {
function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
var url;
if (event.repeats && dayDelta !== 0) {
revertFunc();
return;
}
url = '/Schedule/move-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.overlap) {
revertFunc();
@ -156,7 +151,7 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
url = '/Schedule/resize-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.overlap) {
revertFunc();
@ -167,24 +162,11 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
function getFullCalendarEvents(start, end, callback) {
var url, start_date, end_date;
var sy, sm, sd, ey, em, ed;
sy = start.getFullYear();
sm = start.getMonth() + 1;
sd = start.getDate();
start_date = sy +"-"+ sm +"-"+ sd;
ey = end.getFullYear();
em = end.getMonth() + 1;
ed = end.getDate();
end_date = ey +"-"+ em +"-"+ ed;
start_date = makeTimeStamp(start);
end_date = makeTimeStamp(end);
url = '/Schedule/event-feed';
if ((ed - sd) === 1) {
url = url + '/weekday/' + start.getDay();
}
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){