BaseCcShowInstances.php 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'cc_show_instances' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcShowInstances extends BaseObject implements Persistent
  10. {
  11. /**
  12. * Peer class name
  13. */
  14. const PEER = 'CcShowInstancesPeer';
  15. /**
  16. * The Peer class.
  17. * Instance provides a convenient way of calling static methods on a class
  18. * that calling code may not be able to identify.
  19. * @var CcShowInstancesPeer
  20. */
  21. protected static $peer;
  22. /**
  23. * The value for the id field.
  24. * @var int
  25. */
  26. protected $id;
  27. /**
  28. * The value for the starts field.
  29. * @var string
  30. */
  31. protected $starts;
  32. /**
  33. * The value for the ends field.
  34. * @var string
  35. */
  36. protected $ends;
  37. /**
  38. * The value for the show_id field.
  39. * @var int
  40. */
  41. protected $show_id;
  42. /**
  43. * The value for the record field.
  44. * Note: this column has a database default value of: 0
  45. * @var int
  46. */
  47. protected $record;
  48. /**
  49. * The value for the rebroadcast field.
  50. * Note: this column has a database default value of: 0
  51. * @var int
  52. */
  53. protected $rebroadcast;
  54. /**
  55. * The value for the instance_id field.
  56. * @var int
  57. */
  58. protected $instance_id;
  59. /**
  60. * The value for the file_id field.
  61. * @var int
  62. */
  63. protected $file_id;
  64. /**
  65. * The value for the time_filled field.
  66. * Note: this column has a database default value of: '00:00:00'
  67. * @var string
  68. */
  69. protected $time_filled;
  70. /**
  71. * The value for the created field.
  72. * @var string
  73. */
  74. protected $created;
  75. /**
  76. * The value for the last_scheduled field.
  77. * @var string
  78. */
  79. protected $last_scheduled;
  80. /**
  81. * The value for the modified_instance field.
  82. * Note: this column has a database default value of: false
  83. * @var boolean
  84. */
  85. protected $modified_instance;
  86. /**
  87. * @var CcShow
  88. */
  89. protected $aCcShow;
  90. /**
  91. * @var CcShowInstances
  92. */
  93. protected $aCcShowInstancesRelatedByDbOriginalShow;
  94. /**
  95. * @var CcFiles
  96. */
  97. protected $aCcFiles;
  98. /**
  99. * @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects.
  100. */
  101. protected $collCcShowInstancessRelatedByDbId;
  102. /**
  103. * @var array CcSchedule[] Collection to store aggregation of CcSchedule objects.
  104. */
  105. protected $collCcSchedules;
  106. /**
  107. * @var array CcPlayoutHistory[] Collection to store aggregation of CcPlayoutHistory objects.
  108. */
  109. protected $collCcPlayoutHistorys;
  110. /**
  111. * Flag to prevent endless save loop, if this object is referenced
  112. * by another object which falls in this transaction.
  113. * @var boolean
  114. */
  115. protected $alreadyInSave = false;
  116. /**
  117. * Flag to prevent endless validation loop, if this object is referenced
  118. * by another object which falls in this transaction.
  119. * @var boolean
  120. */
  121. protected $alreadyInValidation = false;
  122. /**
  123. * Applies default values to this object.
  124. * This method should be called from the object's constructor (or
  125. * equivalent initialization method).
  126. * @see __construct()
  127. */
  128. public function applyDefaultValues()
  129. {
  130. $this->record = 0;
  131. $this->rebroadcast = 0;
  132. $this->time_filled = '00:00:00';
  133. $this->modified_instance = false;
  134. }
  135. /**
  136. * Initializes internal state of BaseCcShowInstances object.
  137. * @see applyDefaults()
  138. */
  139. public function __construct()
  140. {
  141. parent::__construct();
  142. $this->applyDefaultValues();
  143. }
  144. /**
  145. * Get the [id] column value.
  146. *
  147. * @return int
  148. */
  149. public function getDbId()
  150. {
  151. return $this->id;
  152. }
  153. /**
  154. * Get the [optionally formatted] temporal [starts] column value.
  155. *
  156. *
  157. * @param string $format The date/time format string (either date()-style or strftime()-style).
  158. * If format is NULL, then the raw DateTime object will be returned.
  159. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  160. * @throws PropelException - if unable to parse/validate the date/time value.
  161. */
  162. public function getDbStarts($format = 'Y-m-d H:i:s')
  163. {
  164. if ($this->starts === null) {
  165. return null;
  166. }
  167. try {
  168. $dt = new DateTime($this->starts);
  169. } catch (Exception $x) {
  170. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x);
  171. }
  172. if ($format === null) {
  173. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  174. return $dt;
  175. } elseif (strpos($format, '%') !== false) {
  176. return strftime($format, $dt->format('U'));
  177. } else {
  178. return $dt->format($format);
  179. }
  180. }
  181. /**
  182. * Get the [optionally formatted] temporal [ends] column value.
  183. *
  184. *
  185. * @param string $format The date/time format string (either date()-style or strftime()-style).
  186. * If format is NULL, then the raw DateTime object will be returned.
  187. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  188. * @throws PropelException - if unable to parse/validate the date/time value.
  189. */
  190. public function getDbEnds($format = 'Y-m-d H:i:s')
  191. {
  192. if ($this->ends === null) {
  193. return null;
  194. }
  195. try {
  196. $dt = new DateTime($this->ends);
  197. } catch (Exception $x) {
  198. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x);
  199. }
  200. if ($format === null) {
  201. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  202. return $dt;
  203. } elseif (strpos($format, '%') !== false) {
  204. return strftime($format, $dt->format('U'));
  205. } else {
  206. return $dt->format($format);
  207. }
  208. }
  209. /**
  210. * Get the [show_id] column value.
  211. *
  212. * @return int
  213. */
  214. public function getDbShowId()
  215. {
  216. return $this->show_id;
  217. }
  218. /**
  219. * Get the [record] column value.
  220. *
  221. * @return int
  222. */
  223. public function getDbRecord()
  224. {
  225. return $this->record;
  226. }
  227. /**
  228. * Get the [rebroadcast] column value.
  229. *
  230. * @return int
  231. */
  232. public function getDbRebroadcast()
  233. {
  234. return $this->rebroadcast;
  235. }
  236. /**
  237. * Get the [instance_id] column value.
  238. *
  239. * @return int
  240. */
  241. public function getDbOriginalShow()
  242. {
  243. return $this->instance_id;
  244. }
  245. /**
  246. * Get the [file_id] column value.
  247. *
  248. * @return int
  249. */
  250. public function getDbRecordedFile()
  251. {
  252. return $this->file_id;
  253. }
  254. /**
  255. * Get the [time_filled] column value.
  256. *
  257. * @return string
  258. */
  259. public function getDbTimeFilled()
  260. {
  261. return $this->time_filled;
  262. }
  263. /**
  264. * Get the [optionally formatted] temporal [created] column value.
  265. *
  266. *
  267. * @param string $format The date/time format string (either date()-style or strftime()-style).
  268. * If format is NULL, then the raw DateTime object will be returned.
  269. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  270. * @throws PropelException - if unable to parse/validate the date/time value.
  271. */
  272. public function getDbCreated($format = 'Y-m-d H:i:s')
  273. {
  274. if ($this->created === null) {
  275. return null;
  276. }
  277. try {
  278. $dt = new DateTime($this->created);
  279. } catch (Exception $x) {
  280. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x);
  281. }
  282. if ($format === null) {
  283. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  284. return $dt;
  285. } elseif (strpos($format, '%') !== false) {
  286. return strftime($format, $dt->format('U'));
  287. } else {
  288. return $dt->format($format);
  289. }
  290. }
  291. /**
  292. * Get the [optionally formatted] temporal [last_scheduled] column value.
  293. *
  294. *
  295. * @param string $format The date/time format string (either date()-style or strftime()-style).
  296. * If format is NULL, then the raw DateTime object will be returned.
  297. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  298. * @throws PropelException - if unable to parse/validate the date/time value.
  299. */
  300. public function getDbLastScheduled($format = 'Y-m-d H:i:s')
  301. {
  302. if ($this->last_scheduled === null) {
  303. return null;
  304. }
  305. try {
  306. $dt = new DateTime($this->last_scheduled);
  307. } catch (Exception $x) {
  308. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, true), $x);
  309. }
  310. if ($format === null) {
  311. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  312. return $dt;
  313. } elseif (strpos($format, '%') !== false) {
  314. return strftime($format, $dt->format('U'));
  315. } else {
  316. return $dt->format($format);
  317. }
  318. }
  319. /**
  320. * Get the [modified_instance] column value.
  321. *
  322. * @return boolean
  323. */
  324. public function getDbModifiedInstance()
  325. {
  326. return $this->modified_instance;
  327. }
  328. /**
  329. * Set the value of [id] column.
  330. *
  331. * @param int $v new value
  332. * @return CcShowInstances The current object (for fluent API support)
  333. */
  334. public function setDbId($v)
  335. {
  336. if ($v !== null) {
  337. $v = (int) $v;
  338. }
  339. if ($this->id !== $v) {
  340. $this->id = $v;
  341. $this->modifiedColumns[] = CcShowInstancesPeer::ID;
  342. }
  343. return $this;
  344. } // setDbId()
  345. /**
  346. * Sets the value of [starts] column to a normalized version of the date/time value specified.
  347. *
  348. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  349. * be treated as NULL for temporal objects.
  350. * @return CcShowInstances The current object (for fluent API support)
  351. */
  352. public function setDbStarts($v)
  353. {
  354. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  355. // -- which is unexpected, to say the least.
  356. if ($v === null || $v === '') {
  357. $dt = null;
  358. } elseif ($v instanceof DateTime) {
  359. $dt = $v;
  360. } else {
  361. // some string/numeric value passed; we normalize that so that we can
  362. // validate it.
  363. try {
  364. if (is_numeric($v)) { // if it's a unix timestamp
  365. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  366. // We have to explicitly specify and then change the time zone because of a
  367. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  368. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  369. } else {
  370. $dt = new DateTime($v);
  371. }
  372. } catch (Exception $x) {
  373. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  374. }
  375. }
  376. if ( $this->starts !== null || $dt !== null ) {
  377. // (nested ifs are a little easier to read in this case)
  378. $currNorm = ($this->starts !== null && $tmpDt = new DateTime($this->starts)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  379. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  380. if ( ($currNorm !== $newNorm) // normalized values don't match
  381. )
  382. {
  383. $this->starts = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  384. $this->modifiedColumns[] = CcShowInstancesPeer::STARTS;
  385. }
  386. } // if either are not null
  387. return $this;
  388. } // setDbStarts()
  389. /**
  390. * Sets the value of [ends] column to a normalized version of the date/time value specified.
  391. *
  392. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  393. * be treated as NULL for temporal objects.
  394. * @return CcShowInstances The current object (for fluent API support)
  395. */
  396. public function setDbEnds($v)
  397. {
  398. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  399. // -- which is unexpected, to say the least.
  400. if ($v === null || $v === '') {
  401. $dt = null;
  402. } elseif ($v instanceof DateTime) {
  403. $dt = $v;
  404. } else {
  405. // some string/numeric value passed; we normalize that so that we can
  406. // validate it.
  407. try {
  408. if (is_numeric($v)) { // if it's a unix timestamp
  409. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  410. // We have to explicitly specify and then change the time zone because of a
  411. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  412. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  413. } else {
  414. $dt = new DateTime($v);
  415. }
  416. } catch (Exception $x) {
  417. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  418. }
  419. }
  420. if ( $this->ends !== null || $dt !== null ) {
  421. // (nested ifs are a little easier to read in this case)
  422. $currNorm = ($this->ends !== null && $tmpDt = new DateTime($this->ends)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  423. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  424. if ( ($currNorm !== $newNorm) // normalized values don't match
  425. )
  426. {
  427. $this->ends = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  428. $this->modifiedColumns[] = CcShowInstancesPeer::ENDS;
  429. }
  430. } // if either are not null
  431. return $this;
  432. } // setDbEnds()
  433. /**
  434. * Set the value of [show_id] column.
  435. *
  436. * @param int $v new value
  437. * @return CcShowInstances The current object (for fluent API support)
  438. */
  439. public function setDbShowId($v)
  440. {
  441. if ($v !== null) {
  442. $v = (int) $v;
  443. }
  444. if ($this->show_id !== $v) {
  445. $this->show_id = $v;
  446. $this->modifiedColumns[] = CcShowInstancesPeer::SHOW_ID;
  447. }
  448. if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) {
  449. $this->aCcShow = null;
  450. }
  451. return $this;
  452. } // setDbShowId()
  453. /**
  454. * Set the value of [record] column.
  455. *
  456. * @param int $v new value
  457. * @return CcShowInstances The current object (for fluent API support)
  458. */
  459. public function setDbRecord($v)
  460. {
  461. if ($v !== null) {
  462. $v = (int) $v;
  463. }
  464. if ($this->record !== $v || $this->isNew()) {
  465. $this->record = $v;
  466. $this->modifiedColumns[] = CcShowInstancesPeer::RECORD;
  467. }
  468. return $this;
  469. } // setDbRecord()
  470. /**
  471. * Set the value of [rebroadcast] column.
  472. *
  473. * @param int $v new value
  474. * @return CcShowInstances The current object (for fluent API support)
  475. */
  476. public function setDbRebroadcast($v)
  477. {
  478. if ($v !== null) {
  479. $v = (int) $v;
  480. }
  481. if ($this->rebroadcast !== $v || $this->isNew()) {
  482. $this->rebroadcast = $v;
  483. $this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST;
  484. }
  485. return $this;
  486. } // setDbRebroadcast()
  487. /**
  488. * Set the value of [instance_id] column.
  489. *
  490. * @param int $v new value
  491. * @return CcShowInstances The current object (for fluent API support)
  492. */
  493. public function setDbOriginalShow($v)
  494. {
  495. if ($v !== null) {
  496. $v = (int) $v;
  497. }
  498. if ($this->instance_id !== $v) {
  499. $this->instance_id = $v;
  500. $this->modifiedColumns[] = CcShowInstancesPeer::INSTANCE_ID;
  501. }
  502. if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId() !== $v) {
  503. $this->aCcShowInstancesRelatedByDbOriginalShow = null;
  504. }
  505. return $this;
  506. } // setDbOriginalShow()
  507. /**
  508. * Set the value of [file_id] column.
  509. *
  510. * @param int $v new value
  511. * @return CcShowInstances The current object (for fluent API support)
  512. */
  513. public function setDbRecordedFile($v)
  514. {
  515. if ($v !== null) {
  516. $v = (int) $v;
  517. }
  518. if ($this->file_id !== $v) {
  519. $this->file_id = $v;
  520. $this->modifiedColumns[] = CcShowInstancesPeer::FILE_ID;
  521. }
  522. if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) {
  523. $this->aCcFiles = null;
  524. }
  525. return $this;
  526. } // setDbRecordedFile()
  527. /**
  528. * Set the value of [time_filled] column.
  529. *
  530. * @param string $v new value
  531. * @return CcShowInstances The current object (for fluent API support)
  532. */
  533. public function setDbTimeFilled($v)
  534. {
  535. if ($v !== null) {
  536. $v = (string) $v;
  537. }
  538. if ($this->time_filled !== $v || $this->isNew()) {
  539. $this->time_filled = $v;
  540. $this->modifiedColumns[] = CcShowInstancesPeer::TIME_FILLED;
  541. }
  542. return $this;
  543. } // setDbTimeFilled()
  544. /**
  545. * Sets the value of [created] column to a normalized version of the date/time value specified.
  546. *
  547. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  548. * be treated as NULL for temporal objects.
  549. * @return CcShowInstances The current object (for fluent API support)
  550. */
  551. public function setDbCreated($v)
  552. {
  553. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  554. // -- which is unexpected, to say the least.
  555. if ($v === null || $v === '') {
  556. $dt = null;
  557. } elseif ($v instanceof DateTime) {
  558. $dt = $v;
  559. } else {
  560. // some string/numeric value passed; we normalize that so that we can
  561. // validate it.
  562. try {
  563. if (is_numeric($v)) { // if it's a unix timestamp
  564. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  565. // We have to explicitly specify and then change the time zone because of a
  566. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  567. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  568. } else {
  569. $dt = new DateTime($v);
  570. }
  571. } catch (Exception $x) {
  572. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  573. }
  574. }
  575. if ( $this->created !== null || $dt !== null ) {
  576. // (nested ifs are a little easier to read in this case)
  577. $currNorm = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  578. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  579. if ( ($currNorm !== $newNorm) // normalized values don't match
  580. )
  581. {
  582. $this->created = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  583. $this->modifiedColumns[] = CcShowInstancesPeer::CREATED;
  584. }
  585. } // if either are not null
  586. return $this;
  587. } // setDbCreated()
  588. /**
  589. * Sets the value of [last_scheduled] column to a normalized version of the date/time value specified.
  590. *
  591. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  592. * be treated as NULL for temporal objects.
  593. * @return CcShowInstances The current object (for fluent API support)
  594. */
  595. public function setDbLastScheduled($v)
  596. {
  597. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  598. // -- which is unexpected, to say the least.
  599. if ($v === null || $v === '') {
  600. $dt = null;
  601. } elseif ($v instanceof DateTime) {
  602. $dt = $v;
  603. } else {
  604. // some string/numeric value passed; we normalize that so that we can
  605. // validate it.
  606. try {
  607. if (is_numeric($v)) { // if it's a unix timestamp
  608. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  609. // We have to explicitly specify and then change the time zone because of a
  610. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  611. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  612. } else {
  613. $dt = new DateTime($v);
  614. }
  615. } catch (Exception $x) {
  616. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  617. }
  618. }
  619. if ( $this->last_scheduled !== null || $dt !== null ) {
  620. // (nested ifs are a little easier to read in this case)
  621. $currNorm = ($this->last_scheduled !== null && $tmpDt = new DateTime($this->last_scheduled)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  622. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  623. if ( ($currNorm !== $newNorm) // normalized values don't match
  624. )
  625. {
  626. $this->last_scheduled = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  627. $this->modifiedColumns[] = CcShowInstancesPeer::LAST_SCHEDULED;
  628. }
  629. } // if either are not null
  630. return $this;
  631. } // setDbLastScheduled()
  632. /**
  633. * Set the value of [modified_instance] column.
  634. *
  635. * @param boolean $v new value
  636. * @return CcShowInstances The current object (for fluent API support)
  637. */
  638. public function setDbModifiedInstance($v)
  639. {
  640. if ($v !== null) {
  641. $v = (boolean) $v;
  642. }
  643. if ($this->modified_instance !== $v || $this->isNew()) {
  644. $this->modified_instance = $v;
  645. $this->modifiedColumns[] = CcShowInstancesPeer::MODIFIED_INSTANCE;
  646. }
  647. return $this;
  648. } // setDbModifiedInstance()
  649. /**
  650. * Indicates whether the columns in this object are only set to default values.
  651. *
  652. * This method can be used in conjunction with isModified() to indicate whether an object is both
  653. * modified _and_ has some values set which are non-default.
  654. *
  655. * @return boolean Whether the columns in this object are only been set with default values.
  656. */
  657. public function hasOnlyDefaultValues()
  658. {
  659. if ($this->record !== 0) {
  660. return false;
  661. }
  662. if ($this->rebroadcast !== 0) {
  663. return false;
  664. }
  665. if ($this->time_filled !== '00:00:00') {
  666. return false;
  667. }
  668. if ($this->modified_instance !== false) {
  669. return false;
  670. }
  671. // otherwise, everything was equal, so return TRUE
  672. return true;
  673. } // hasOnlyDefaultValues()
  674. /**
  675. * Hydrates (populates) the object variables with values from the database resultset.
  676. *
  677. * An offset (0-based "start column") is specified so that objects can be hydrated
  678. * with a subset of the columns in the resultset rows. This is needed, for example,
  679. * for results of JOIN queries where the resultset row includes columns from two or
  680. * more tables.
  681. *
  682. * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  683. * @param int $startcol 0-based offset column which indicates which restultset column to start with.
  684. * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
  685. * @return int next starting column
  686. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  687. */
  688. public function hydrate($row, $startcol = 0, $rehydrate = false)
  689. {
  690. try {
  691. $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
  692. $this->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
  693. $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
  694. $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
  695. $this->record = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
  696. $this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
  697. $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
  698. $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
  699. $this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
  700. $this->created = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
  701. $this->last_scheduled = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
  702. $this->modified_instance = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null;
  703. $this->resetModified();
  704. $this->setNew(false);
  705. if ($rehydrate) {
  706. $this->ensureConsistency();
  707. }
  708. return $startcol + 12; // 12 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
  709. } catch (Exception $e) {
  710. throw new PropelException("Error populating CcShowInstances object", $e);
  711. }
  712. }
  713. /**
  714. * Checks and repairs the internal consistency of the object.
  715. *
  716. * This method is executed after an already-instantiated object is re-hydrated
  717. * from the database. It exists to check any foreign keys to make sure that
  718. * the objects related to the current object are correct based on foreign key.
  719. *
  720. * You can override this method in the stub class, but you should always invoke
  721. * the base method from the overridden method (i.e. parent::ensureConsistency()),
  722. * in case your model changes.
  723. *
  724. * @throws PropelException
  725. */
  726. public function ensureConsistency()
  727. {
  728. if ($this->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) {
  729. $this->aCcShow = null;
  730. }
  731. if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->instance_id !== $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId()) {
  732. $this->aCcShowInstancesRelatedByDbOriginalShow = null;
  733. }
  734. if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) {
  735. $this->aCcFiles = null;
  736. }
  737. } // ensureConsistency
  738. /**
  739. * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  740. *
  741. * This will only work if the object has been saved and has a valid primary key set.
  742. *
  743. * @param boolean $deep (optional) Whether to also de-associated any related objects.
  744. * @param PropelPDO $con (optional) The PropelPDO connection to use.
  745. * @return void
  746. * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  747. */
  748. public function reload($deep = false, PropelPDO $con = null)
  749. {
  750. if ($this->isDeleted()) {
  751. throw new PropelException("Cannot reload a deleted object.");
  752. }
  753. if ($this->isNew()) {
  754. throw new PropelException("Cannot reload an unsaved object.");
  755. }
  756. if ($con === null) {
  757. $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  758. }
  759. // We don't need to alter the object instance pool; we're just modifying this instance
  760. // already in the pool.
  761. $stmt = CcShowInstancesPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  762. $row = $stmt->fetch(PDO::FETCH_NUM);
  763. $stmt->closeCursor();
  764. if (!$row) {
  765. throw new PropelException('Cannot find matching row in the database to reload object values.');
  766. }
  767. $this->hydrate($row, 0, true); // rehydrate
  768. if ($deep) { // also de-associate any related objects?
  769. $this->aCcShow = null;
  770. $this->aCcShowInstancesRelatedByDbOriginalShow = null;
  771. $this->aCcFiles = null;
  772. $this->collCcShowInstancessRelatedByDbId = null;
  773. $this->collCcSchedules = null;
  774. $this->collCcPlayoutHistorys = null;
  775. } // if (deep)
  776. }
  777. /**
  778. * Removes this object from datastore and sets delete attribute.
  779. *
  780. * @param PropelPDO $con
  781. * @return void
  782. * @throws PropelException
  783. * @see BaseObject::setDeleted()
  784. * @see BaseObject::isDeleted()
  785. */
  786. public function delete(PropelPDO $con = null)
  787. {
  788. if ($this->isDeleted()) {
  789. throw new PropelException("This object has already been deleted.");
  790. }
  791. if ($con === null) {
  792. $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  793. }
  794. $con->beginTransaction();
  795. try {
  796. $ret = $this->preDelete($con);
  797. if ($ret) {
  798. CcShowInstancesQuery::create()
  799. ->filterByPrimaryKey($this->getPrimaryKey())
  800. ->delete($con);
  801. $this->postDelete($con);
  802. $con->commit();
  803. $this->setDeleted(true);
  804. } else {
  805. $con->commit();
  806. }
  807. } catch (PropelException $e) {
  808. $con->rollBack();
  809. throw $e;
  810. }
  811. }
  812. /**
  813. * Persists this object to the database.
  814. *
  815. * If the object is new, it inserts it; otherwise an update is performed.
  816. * All modified related objects will also be persisted in the doSave()
  817. * method. This method wraps all precipitate database operations in a
  818. * single transaction.
  819. *
  820. * @param PropelPDO $con
  821. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  822. * @throws PropelException
  823. * @see doSave()
  824. */
  825. public function save(PropelPDO $con = null)
  826. {
  827. if ($this->isDeleted()) {
  828. throw new PropelException("You cannot save an object that has been deleted.");
  829. }
  830. if ($con === null) {
  831. $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  832. }
  833. $con->beginTransaction();
  834. $isInsert = $this->isNew();
  835. try {
  836. $ret = $this->preSave($con);
  837. if ($isInsert) {
  838. $ret = $ret && $this->preInsert($con);
  839. } else {
  840. $ret = $ret && $this->preUpdate($con);
  841. }
  842. if ($ret) {
  843. $affectedRows = $this->doSave($con);
  844. if ($isInsert) {
  845. $this->postInsert($con);
  846. } else {
  847. $this->postUpdate($con);
  848. }
  849. $this->postSave($con);
  850. CcShowInstancesPeer::addInstanceToPool($this);
  851. } else {
  852. $affectedRows = 0;
  853. }
  854. $con->commit();
  855. return $affectedRows;
  856. } catch (PropelException $e) {
  857. $con->rollBack();
  858. throw $e;
  859. }
  860. }
  861. /**
  862. * Performs the work of inserting or updating the row in the database.
  863. *
  864. * If the object is new, it inserts it; otherwise an update is performed.
  865. * All related objects are also updated in this method.
  866. *
  867. * @param PropelPDO $con
  868. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  869. * @throws PropelException
  870. * @see save()
  871. */
  872. protected function doSave(PropelPDO $con)
  873. {
  874. $affectedRows = 0; // initialize var to track total num of affected rows
  875. if (!$this->alreadyInSave) {
  876. $this->alreadyInSave = true;
  877. // We call the save method on the following object(s) if they
  878. // were passed to this object by their coresponding set
  879. // method. This object relates to these object(s) by a
  880. // foreign key reference.
  881. if ($this->aCcShow !== null) {
  882. if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) {
  883. $affectedRows += $this->aCcShow->save($con);
  884. }
  885. $this->setCcShow($this->aCcShow);
  886. }
  887. if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) {
  888. if ($this->aCcShowInstancesRelatedByDbOriginalShow->isModified() || $this->aCcShowInstancesRelatedByDbOriginalShow->isNew()) {
  889. $affectedRows += $this->aCcShowInstancesRelatedByDbOriginalShow->save($con);
  890. }
  891. $this->setCcShowInstancesRelatedByDbOriginalShow($this->aCcShowInstancesRelatedByDbOriginalShow);
  892. }
  893. if ($this->aCcFiles !== null) {
  894. if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) {
  895. $affectedRows += $this->aCcFiles->save($con);
  896. }
  897. $this->setCcFiles($this->aCcFiles);
  898. }
  899. if ($this->isNew() ) {
  900. $this->modifiedColumns[] = CcShowInstancesPeer::ID;
  901. }
  902. // If this object has been modified, then save it to the database.
  903. if ($this->isModified()) {
  904. if ($this->isNew()) {
  905. $criteria = $this->buildCriteria();
  906. if ($criteria->keyContainsValue(CcShowInstancesPeer::ID) ) {
  907. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowInstancesPeer::ID.')');
  908. }
  909. $pk = BasePeer::doInsert($criteria, $con);
  910. $affectedRows += 1;
  911. $this->setDbId($pk); //[IMV] update autoincrement primary key
  912. $this->setNew(false);
  913. } else {
  914. $affectedRows += CcShowInstancesPeer::doUpdate($this, $con);
  915. }
  916. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  917. }
  918. if ($this->collCcShowInstancessRelatedByDbId !== null) {
  919. foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) {
  920. if (!$referrerFK->isDeleted()) {
  921. $affectedRows += $referrerFK->save($con);
  922. }
  923. }
  924. }
  925. if ($this->collCcSchedules !== null) {
  926. foreach ($this->collCcSchedules as $referrerFK) {
  927. if (!$referrerFK->isDeleted()) {
  928. $affectedRows += $referrerFK->save($con);
  929. }
  930. }
  931. }
  932. if ($this->collCcPlayoutHistorys !== null) {
  933. foreach ($this->collCcPlayoutHistorys as $referrerFK) {
  934. if (!$referrerFK->isDeleted()) {
  935. $affectedRows += $referrerFK->save($con);
  936. }
  937. }
  938. }
  939. $this->alreadyInSave = false;
  940. }
  941. return $affectedRows;
  942. } // doSave()
  943. /**
  944. * Array of ValidationFailed objects.
  945. * @var array ValidationFailed[]
  946. */
  947. protected $validationFailures = array();
  948. /**
  949. * Gets any ValidationFailed objects that resulted from last call to validate().
  950. *
  951. *
  952. * @return array ValidationFailed[]
  953. * @see validate()
  954. */
  955. public function getValidationFailures()
  956. {
  957. return $this->validationFailures;
  958. }
  959. /**
  960. * Validates the objects modified field values and all objects related to this table.
  961. *
  962. * If $columns is either a column name or an array of column names
  963. * only those columns are validated.
  964. *
  965. * @param mixed $columns Column name or an array of column names.
  966. * @return boolean Whether all columns pass validation.
  967. * @see doValidate()
  968. * @see getValidationFailures()
  969. */
  970. public function validate($columns = null)
  971. {
  972. $res = $this->doValidate($columns);
  973. if ($res === true) {
  974. $this->validationFailures = array();
  975. return true;
  976. } else {
  977. $this->validationFailures = $res;
  978. return false;
  979. }
  980. }
  981. /**
  982. * This function performs the validation work for complex object models.
  983. *
  984. * In addition to checking the current object, all related objects will
  985. * also be validated. If all pass then <code>true</code> is returned; otherwise
  986. * an aggreagated array of ValidationFailed objects will be returned.
  987. *
  988. * @param array $columns Array of column names to validate.
  989. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  990. */
  991. protected function doValidate($columns = null)
  992. {
  993. if (!$this->alreadyInValidation) {
  994. $this->alreadyInValidation = true;
  995. $retval = null;
  996. $failureMap = array();
  997. // We call the validate method on the following object(s) if they
  998. // were passed to this object by their coresponding set
  999. // method. This object relates to these object(s) by a
  1000. // foreign key reference.
  1001. if ($this->aCcShow !== null) {
  1002. if (!$this->aCcShow->validate($columns)) {
  1003. $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures());
  1004. }
  1005. }
  1006. if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) {
  1007. if (!$this->aCcShowInstancesRelatedByDbOriginalShow->validate($columns)) {
  1008. $failureMap = array_merge($failureMap, $this->aCcShowInstancesRelatedByDbOriginalShow->getValidationFailures());
  1009. }
  1010. }
  1011. if ($this->aCcFiles !== null) {
  1012. if (!$this->aCcFiles->validate($columns)) {
  1013. $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures());
  1014. }
  1015. }
  1016. if (($retval = CcShowInstancesPeer::doValidate($this, $columns)) !== true) {
  1017. $failureMap = array_merge($failureMap, $retval);
  1018. }
  1019. if ($this->collCcShowInstancessRelatedByDbId !== null) {
  1020. foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) {
  1021. if (!$referrerFK->validate($columns)) {
  1022. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  1023. }
  1024. }
  1025. }
  1026. if ($this->collCcSchedules !== null) {
  1027. foreach ($this->collCcSchedules as $referrerFK) {
  1028. if (!$referrerFK->validate($columns)) {
  1029. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  1030. }
  1031. }
  1032. }
  1033. if ($this->collCcPlayoutHistorys !== null) {
  1034. foreach ($this->collCcPlayoutHistorys as $referrerFK) {
  1035. if (!$referrerFK->validate($columns)) {
  1036. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  1037. }
  1038. }
  1039. }
  1040. $this->alreadyInValidation = false;
  1041. }
  1042. return (!empty($failureMap) ? $failureMap : true);
  1043. }
  1044. /**
  1045. * Retrieves a field from the object by name passed in as a string.
  1046. *
  1047. * @param string $name name
  1048. * @param string $type The type of fieldname the $name is of:
  1049. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1050. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  1051. * @return mixed Value of field.
  1052. */
  1053. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  1054. {
  1055. $pos = CcShowInstancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  1056. $field = $this->getByPosition($pos);
  1057. return $field;
  1058. }
  1059. /**
  1060. * Retrieves a field from the object by Position as specified in the xml schema.
  1061. * Zero-based.
  1062. *
  1063. * @param int $pos position in xml schema
  1064. * @return mixed Value of field at $pos
  1065. */
  1066. public function getByPosition($pos)
  1067. {
  1068. switch($pos) {
  1069. case 0:
  1070. return $this->getDbId();
  1071. break;
  1072. case 1:
  1073. return $this->getDbStarts();
  1074. break;
  1075. case 2:
  1076. return $this->getDbEnds();
  1077. break;
  1078. case 3:
  1079. return $this->getDbShowId();
  1080. break;
  1081. case 4:
  1082. return $this->getDbRecord();
  1083. break;
  1084. case 5:
  1085. return $this->getDbRebroadcast();
  1086. break;
  1087. case 6:
  1088. return $this->getDbOriginalShow();
  1089. break;
  1090. case 7:
  1091. return $this->getDbRecordedFile();
  1092. break;
  1093. case 8:
  1094. return $this->getDbTimeFilled();
  1095. break;
  1096. case 9:
  1097. return $this->getDbCreated();
  1098. break;
  1099. case 10:
  1100. return $this->getDbLastScheduled();
  1101. break;
  1102. case 11:
  1103. return $this->getDbModifiedInstance();
  1104. break;
  1105. default:
  1106. return null;
  1107. break;
  1108. } // switch()
  1109. }
  1110. /**
  1111. * Exports the object as an array.
  1112. *
  1113. * You can specify the key type of the array by passing one of the class
  1114. * type constants.
  1115. *
  1116. * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1117. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1118. * Defaults to BasePeer::TYPE_PHPNAME.
  1119. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  1120. * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  1121. *
  1122. * @return array an associative array containing the field names (as keys) and field values
  1123. */
  1124. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false)
  1125. {
  1126. $keys = CcShowInstancesPeer::getFieldNames($keyType);
  1127. $result = array(
  1128. $keys[0] => $this->getDbId(),
  1129. $keys[1] => $this->getDbStarts(),
  1130. $keys[2] => $this->getDbEnds(),
  1131. $keys[3] => $this->getDbShowId(),
  1132. $keys[4] => $this->getDbRecord(),
  1133. $keys[5] => $this->getDbRebroadcast(),
  1134. $keys[6] => $this->getDbOriginalShow(),
  1135. $keys[7] => $this->getDbRecordedFile(),
  1136. $keys[8] => $this->getDbTimeFilled(),
  1137. $keys[9] => $this->getDbCreated(),
  1138. $keys[10] => $this->getDbLastScheduled(),
  1139. $keys[11] => $this->getDbModifiedInstance(),
  1140. );
  1141. if ($includeForeignObjects) {
  1142. if (null !== $this->aCcShow) {
  1143. $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, true);
  1144. }
  1145. if (null !== $this->aCcShowInstancesRelatedByDbOriginalShow) {
  1146. $result['CcShowInstancesRelatedByDbOriginalShow'] = $this->aCcShowInstancesRelatedByDbOriginalShow->toArray($keyType, $includeLazyLoadColumns, true);
  1147. }
  1148. if (null !== $this->aCcFiles) {
  1149. $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true);
  1150. }
  1151. }
  1152. return $result;
  1153. }
  1154. /**
  1155. * Sets a field from the object by name passed in as a string.
  1156. *
  1157. * @param string $name peer name
  1158. * @param mixed $value field value
  1159. * @param string $type The type of fieldname the $name is of:
  1160. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1161. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  1162. * @return void
  1163. */
  1164. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  1165. {
  1166. $pos = CcShowInstancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  1167. return $this->setByPosition($pos, $value);
  1168. }
  1169. /**
  1170. * Sets a field from the object by Position as specified in the xml schema.
  1171. * Zero-based.
  1172. *
  1173. * @param int $pos position in xml schema
  1174. * @param mixed $value field value
  1175. * @return void
  1176. */
  1177. public function setByPosition($pos, $value)
  1178. {
  1179. switch($pos) {
  1180. case 0:
  1181. $this->setDbId($value);
  1182. break;
  1183. case 1:
  1184. $this->setDbStarts($value);
  1185. break;
  1186. case 2:
  1187. $this->setDbEnds($value);
  1188. break;
  1189. case 3:
  1190. $this->setDbShowId($value);
  1191. break;
  1192. case 4:
  1193. $this->setDbRecord($value);
  1194. break;
  1195. case 5:
  1196. $this->setDbRebroadcast($value);
  1197. break;
  1198. case 6:
  1199. $this->setDbOriginalShow($value);
  1200. break;
  1201. case 7:
  1202. $this->setDbRecordedFile($value);
  1203. break;
  1204. case 8:
  1205. $this->setDbTimeFilled($value);
  1206. break;
  1207. case 9:
  1208. $this->setDbCreated($value);
  1209. break;
  1210. case 10:
  1211. $this->setDbLastScheduled($value);
  1212. break;
  1213. case 11:
  1214. $this->setDbModifiedInstance($value);
  1215. break;
  1216. } // switch()
  1217. }
  1218. /**
  1219. * Populates the object using an array.
  1220. *
  1221. * This is particularly useful when populating an object from one of the
  1222. * request arrays (e.g. $_POST). This method goes through the column
  1223. * names, checking to see whether a matching key exists in populated
  1224. * array. If so the setByName() method is called for that column.
  1225. *
  1226. * You can specify the key type of the array by additionally passing one
  1227. * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1228. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1229. * The default key type is the column's phpname (e.g. 'AuthorId')
  1230. *
  1231. * @param array $arr An array to populate the object from.
  1232. * @param string $keyType The type of keys the array uses.
  1233. * @return void
  1234. */
  1235. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  1236. {
  1237. $keys = CcShowInstancesPeer::getFieldNames($keyType);
  1238. if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
  1239. if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]);
  1240. if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]);
  1241. if (array_key_exists($keys[3], $arr)) $this->setDbShowId($arr[$keys[3]]);
  1242. if (array_key_exists($keys[4], $arr)) $this->setDbRecord($arr[$keys[4]]);
  1243. if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]);
  1244. if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
  1245. if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
  1246. if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]);
  1247. if (array_key_exists($keys[9], $arr)) $this->setDbCreated($arr[$keys[9]]);
  1248. if (array_key_exists($keys[10], $arr)) $this->setDbLastScheduled($arr[$keys[10]]);
  1249. if (array_key_exists($keys[11], $arr)) $this->setDbModifiedInstance($arr[$keys[11]]);
  1250. }
  1251. /**
  1252. * Build a Criteria object containing the values of all modified columns in this object.
  1253. *
  1254. * @return Criteria The Criteria object containing all modified values.
  1255. */
  1256. public function buildCriteria()
  1257. {
  1258. $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME);
  1259. if ($this->isColumnModified(CcShowInstancesPeer::ID)) $criteria->add(CcShowInstancesPeer::ID, $this->id);
  1260. if ($this->isColumnModified(CcShowInstancesPeer::STARTS)) $criteria->add(CcShowInstancesPeer::STARTS, $this->starts);
  1261. if ($this->isColumnModified(CcShowInstancesPeer::ENDS)) $criteria->add(CcShowInstancesPeer::ENDS, $this->ends);
  1262. if ($this->isColumnModified(CcShowInstancesPeer::SHOW_ID)) $criteria->add(CcShowInstancesPeer::SHOW_ID, $this->show_id);
  1263. if ($this->isColumnModified(CcShowInstancesPeer::RECORD)) $criteria->add(CcShowInstancesPeer::RECORD, $this->record);
  1264. if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast);
  1265. if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
  1266. if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
  1267. if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled);
  1268. if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created);
  1269. if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled);
  1270. if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance);
  1271. return $criteria;
  1272. }
  1273. /**
  1274. * Builds a Criteria object containing the primary key for this object.
  1275. *
  1276. * Unlike buildCriteria() this method includes the primary key values regardless
  1277. * of whether or not they have been modified.
  1278. *
  1279. * @return Criteria The Criteria object containing value(s) for primary key(s).
  1280. */
  1281. public function buildPkeyCriteria()
  1282. {
  1283. $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME);
  1284. $criteria->add(CcShowInstancesPeer::ID, $this->id);
  1285. return $criteria;
  1286. }
  1287. /**
  1288. * Returns the primary key for this object (row).
  1289. * @return int
  1290. */
  1291. public function getPrimaryKey()
  1292. {
  1293. return $this->getDbId();
  1294. }
  1295. /**
  1296. * Generic method to set the primary key (id column).
  1297. *
  1298. * @param int $key Primary key.
  1299. * @return void
  1300. */
  1301. public function setPrimaryKey($key)
  1302. {
  1303. $this->setDbId($key);
  1304. }
  1305. /**
  1306. * Returns true if the primary key for this object is null.
  1307. * @return boolean
  1308. */
  1309. public function isPrimaryKeyNull()
  1310. {
  1311. return null === $this->getDbId();
  1312. }
  1313. /**
  1314. * Sets contents of passed object to values from current object.
  1315. *
  1316. * If desired, this method can also make copies of all associated (fkey referrers)
  1317. * objects.
  1318. *
  1319. * @param object $copyObj An object of CcShowInstances (or compatible) type.
  1320. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1321. * @throws PropelException
  1322. */
  1323. public function copyInto($copyObj, $deepCopy = false)
  1324. {
  1325. $copyObj->setDbStarts($this->starts);
  1326. $copyObj->setDbEnds($this->ends);
  1327. $copyObj->setDbShowId($this->show_id);
  1328. $copyObj->setDbRecord($this->record);
  1329. $copyObj->setDbRebroadcast($this->rebroadcast);
  1330. $copyObj->setDbOriginalShow($this->instance_id);
  1331. $copyObj->setDbRecordedFile($this->file_id);
  1332. $copyObj->setDbTimeFilled($this->time_filled);
  1333. $copyObj->setDbCreated($this->created);
  1334. $copyObj->setDbLastScheduled($this->last_scheduled);
  1335. $copyObj->setDbModifiedInstance($this->modified_instance);
  1336. if ($deepCopy) {
  1337. // important: temporarily setNew(false) because this affects the behavior of
  1338. // the getter/setter methods for fkey referrer objects.
  1339. $copyObj->setNew(false);
  1340. foreach ($this->getCcShowInstancessRelatedByDbId() as $relObj) {
  1341. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1342. $copyObj->addCcShowInstancesRelatedByDbId($relObj->copy($deepCopy));
  1343. }
  1344. }
  1345. foreach ($this->getCcSchedules() as $relObj) {
  1346. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1347. $copyObj->addCcSchedule($relObj->copy($deepCopy));
  1348. }
  1349. }
  1350. foreach ($this->getCcPlayoutHistorys() as $relObj) {
  1351. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1352. $copyObj->addCcPlayoutHistory($relObj->copy($deepCopy));
  1353. }
  1354. }
  1355. } // if ($deepCopy)
  1356. $copyObj->setNew(true);
  1357. $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
  1358. }
  1359. /**
  1360. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1361. * It creates a new object filling in the simple attributes, but skipping any primary
  1362. * keys that are defined for the table.
  1363. *
  1364. * If desired, this method can also make copies of all associated (fkey referrers)
  1365. * objects.
  1366. *
  1367. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1368. * @return CcShowInstances Clone of current object.
  1369. * @throws PropelException
  1370. */
  1371. public function copy($deepCopy = false)
  1372. {
  1373. // we use get_class(), because this might be a subclass
  1374. $clazz = get_class($this);
  1375. $copyObj = new $clazz();
  1376. $this->copyInto($copyObj, $deepCopy);
  1377. return $copyObj;
  1378. }
  1379. /**
  1380. * Returns a peer instance associated with this om.
  1381. *
  1382. * Since Peer classes are not to have any instance attributes, this method returns the
  1383. * same instance for all member of this class. The method could therefore
  1384. * be static, but this would prevent one from overriding the behavior.
  1385. *
  1386. * @return CcShowInstancesPeer
  1387. */
  1388. public function getPeer()
  1389. {
  1390. if (self::$peer === null) {
  1391. self::$peer = new CcShowInstancesPeer();
  1392. }
  1393. return self::$peer;
  1394. }
  1395. /**
  1396. * Declares an association between this object and a CcShow object.
  1397. *
  1398. * @param CcShow $v
  1399. * @return CcShowInstances The current object (for fluent API support)
  1400. * @throws PropelException
  1401. */
  1402. public function setCcShow(CcShow $v = null)
  1403. {
  1404. if ($v === null) {
  1405. $this->setDbShowId(NULL);
  1406. } else {
  1407. $this->setDbShowId($v->getDbId());
  1408. }
  1409. $this->aCcShow = $v;
  1410. // Add binding for other direction of this n:n relationship.
  1411. // If this object has already been added to the CcShow object, it will not be re-added.
  1412. if ($v !== null) {
  1413. $v->addCcShowInstances($this);
  1414. }
  1415. return $this;
  1416. }
  1417. /**
  1418. * Get the associated CcShow object
  1419. *
  1420. * @param PropelPDO Optional Connection object.
  1421. * @return CcShow The associated CcShow object.
  1422. * @throws PropelException
  1423. */
  1424. public function getCcShow(PropelPDO $con = null)
  1425. {
  1426. if ($this->aCcShow === null && ($this->show_id !== null)) {
  1427. $this->aCcShow = CcShowQuery::create()->findPk($this->show_id, $con);
  1428. /* The following can be used additionally to
  1429. guarantee the related object contains a reference
  1430. to this object. This level of coupling may, however, be
  1431. undesirable since it could result in an only partially populated collection
  1432. in the referenced object.
  1433. $this->aCcShow->addCcShowInstancess($this);
  1434. */
  1435. }
  1436. return $this->aCcShow;
  1437. }
  1438. /**
  1439. * Declares an association between this object and a CcShowInstances object.
  1440. *
  1441. * @param CcShowInstances $v
  1442. * @return CcShowInstances The current object (for fluent API support)
  1443. * @throws PropelException
  1444. */
  1445. public function setCcShowInstancesRelatedByDbOriginalShow(CcShowInstances $v = null)
  1446. {
  1447. if ($v === null) {
  1448. $this->setDbOriginalShow(NULL);
  1449. } else {
  1450. $this->setDbOriginalShow($v->getDbId());
  1451. }
  1452. $this->aCcShowInstancesRelatedByDbOriginalShow = $v;
  1453. // Add binding for other direction of this n:n relationship.
  1454. // If this object has already been added to the CcShowInstances object, it will not be re-added.
  1455. if ($v !== null) {
  1456. $v->addCcShowInstancesRelatedByDbId($this);
  1457. }
  1458. return $this;
  1459. }
  1460. /**
  1461. * Get the associated CcShowInstances object
  1462. *
  1463. * @param PropelPDO Optional Connection object.
  1464. * @return CcShowInstances The associated CcShowInstances object.
  1465. * @throws PropelException
  1466. */
  1467. public function getCcShowInstancesRelatedByDbOriginalShow(PropelPDO $con = null)
  1468. {
  1469. if ($this->aCcShowInstancesRelatedByDbOriginalShow === null && ($this->instance_id !== null)) {
  1470. $this->aCcShowInstancesRelatedByDbOriginalShow = CcShowInstancesQuery::create()->findPk($this->instance_id, $con);
  1471. /* The following can be used additionally to
  1472. guarantee the related object contains a reference
  1473. to this object. This level of coupling may, however, be
  1474. undesirable since it could result in an only partially populated collection
  1475. in the referenced object.
  1476. $this->aCcShowInstancesRelatedByDbOriginalShow->addCcShowInstancessRelatedByDbId($this);
  1477. */
  1478. }
  1479. return $this->aCcShowInstancesRelatedByDbOriginalShow;
  1480. }
  1481. /**
  1482. * Declares an association between this object and a CcFiles object.
  1483. *
  1484. * @param CcFiles $v
  1485. * @return CcShowInstances The current object (for fluent API support)
  1486. * @throws PropelException
  1487. */
  1488. public function setCcFiles(CcFiles $v = null)
  1489. {
  1490. if ($v === null) {
  1491. $this->setDbRecordedFile(NULL);
  1492. } else {
  1493. $this->setDbRecordedFile($v->getDbId());
  1494. }
  1495. $this->aCcFiles = $v;
  1496. // Add binding for other direction of this n:n relationship.
  1497. // If this object has already been added to the CcFiles object, it will not be re-added.
  1498. if ($v !== null) {
  1499. $v->addCcShowInstances($this);
  1500. }
  1501. return $this;
  1502. }
  1503. /**
  1504. * Get the associated CcFiles object
  1505. *
  1506. * @param PropelPDO Optional Connection object.
  1507. * @return CcFiles The associated CcFiles object.
  1508. * @throws PropelException
  1509. */
  1510. public function getCcFiles(PropelPDO $con = null)
  1511. {
  1512. if ($this->aCcFiles === null && ($this->file_id !== null)) {
  1513. $this->aCcFiles = CcFilesQuery::create()->findPk($this->file_id, $con);
  1514. /* The following can be used additionally to
  1515. guarantee the related object contains a reference
  1516. to this object. This level of coupling may, however, be
  1517. undesirable since it could result in an only partially populated collection
  1518. in the referenced object.
  1519. $this->aCcFiles->addCcShowInstancess($this);
  1520. */
  1521. }
  1522. return $this->aCcFiles;
  1523. }
  1524. /**
  1525. * Clears out the collCcShowInstancessRelatedByDbId collection
  1526. *
  1527. * This does not modify the database; however, it will remove any associated objects, causing
  1528. * them to be refetched by subsequent calls to accessor method.
  1529. *
  1530. * @return void
  1531. * @see addCcShowInstancessRelatedByDbId()
  1532. */
  1533. public function clearCcShowInstancessRelatedByDbId()
  1534. {
  1535. $this->collCcShowInstancessRelatedByDbId = null; // important to set this to NULL since that means it is uninitialized
  1536. }
  1537. /**
  1538. * Initializes the collCcShowInstancessRelatedByDbId collection.
  1539. *
  1540. * By default this just sets the collCcShowInstancessRelatedByDbId collection to an empty array (like clearcollCcShowInstancessRelatedByDbId());
  1541. * however, you may wish to override this method in your stub class to provide setting appropriate
  1542. * to your application -- for example, setting the initial array to the values stored in database.
  1543. *
  1544. * @return void
  1545. */
  1546. public function initCcShowInstancessRelatedByDbId()
  1547. {
  1548. $this->collCcShowInstancessRelatedByDbId = new PropelObjectCollection();
  1549. $this->collCcShowInstancessRelatedByDbId->setModel('CcShowInstances');
  1550. }
  1551. /**
  1552. * Gets an array of CcShowInstances objects which contain a foreign key that references this object.
  1553. *
  1554. * If the $criteria is not null, it is used to always fetch the results from the database.
  1555. * Otherwise the results are fetched from the database the first time, then cached.
  1556. * Next time the same method is called without $criteria, the cached collection is returned.
  1557. * If this CcShowInstances is new, it will return
  1558. * an empty collection or the current collection; the criteria is ignored on a new object.
  1559. *
  1560. * @param Criteria $criteria optional Criteria object to narrow the query
  1561. * @param PropelPDO $con optional connection object
  1562. * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
  1563. * @throws PropelException
  1564. */
  1565. public function getCcShowInstancessRelatedByDbId($criteria = null, PropelPDO $con = null)
  1566. {
  1567. if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) {
  1568. if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) {
  1569. // return empty collection
  1570. $this->initCcShowInstancessRelatedByDbId();
  1571. } else {
  1572. $collCcShowInstancessRelatedByDbId = CcShowInstancesQuery::create(null, $criteria)
  1573. ->filterByCcShowInstancesRelatedByDbOriginalShow($this)
  1574. ->find($con);
  1575. if (null !== $criteria) {
  1576. return $collCcShowInstancessRelatedByDbId;
  1577. }
  1578. $this->collCcShowInstancessRelatedByDbId = $collCcShowInstancessRelatedByDbId;
  1579. }
  1580. }
  1581. return $this->collCcShowInstancessRelatedByDbId;
  1582. }
  1583. /**
  1584. * Returns the number of related CcShowInstances objects.
  1585. *
  1586. * @param Criteria $criteria
  1587. * @param boolean $distinct
  1588. * @param PropelPDO $con
  1589. * @return int Count of related CcShowInstances objects.
  1590. * @throws PropelException
  1591. */
  1592. public function countCcShowInstancessRelatedByDbId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1593. {
  1594. if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) {
  1595. if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) {
  1596. return 0;
  1597. } else {
  1598. $query = CcShowInstancesQuery::create(null, $criteria);
  1599. if($distinct) {
  1600. $query->distinct();
  1601. }
  1602. return $query
  1603. ->filterByCcShowInstancesRelatedByDbOriginalShow($this)
  1604. ->count($con);
  1605. }
  1606. } else {
  1607. return count($this->collCcShowInstancessRelatedByDbId);
  1608. }
  1609. }
  1610. /**
  1611. * Method called to associate a CcShowInstances object to this object
  1612. * through the CcShowInstances foreign key attribute.
  1613. *
  1614. * @param CcShowInstances $l CcShowInstances
  1615. * @return void
  1616. * @throws PropelException
  1617. */
  1618. public function addCcShowInstancesRelatedByDbId(CcShowInstances $l)
  1619. {
  1620. if ($this->collCcShowInstancessRelatedByDbId === null) {
  1621. $this->initCcShowInstancessRelatedByDbId();
  1622. }
  1623. if (!$this->collCcShowInstancessRelatedByDbId->contains($l)) { // only add it if the **same** object is not already associated
  1624. $this->collCcShowInstancessRelatedByDbId[]= $l;
  1625. $l->setCcShowInstancesRelatedByDbOriginalShow($this);
  1626. }
  1627. }
  1628. /**
  1629. * If this collection has already been initialized with
  1630. * an identical criteria, it returns the collection.
  1631. * Otherwise if this CcShowInstances is new, it will return
  1632. * an empty collection; or if this CcShowInstances has previously
  1633. * been saved, it will retrieve related CcShowInstancessRelatedByDbId from storage.
  1634. *
  1635. * This method is protected by default in order to keep the public
  1636. * api reasonable. You can provide public methods for those you
  1637. * actually need in CcShowInstances.
  1638. *
  1639. * @param Criteria $criteria optional Criteria object to narrow the query
  1640. * @param PropelPDO $con optional connection object
  1641. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1642. * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
  1643. */
  1644. public function getCcShowInstancessRelatedByDbIdJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1645. {
  1646. $query = CcShowInstancesQuery::create(null, $criteria);
  1647. $query->joinWith('CcShow', $join_behavior);
  1648. return $this->getCcShowInstancessRelatedByDbId($query, $con);
  1649. }
  1650. /**
  1651. * If this collection has already been initialized with
  1652. * an identical criteria, it returns the collection.
  1653. * Otherwise if this CcShowInstances is new, it will return
  1654. * an empty collection; or if this CcShowInstances has previously
  1655. * been saved, it will retrieve related CcShowInstancessRelatedByDbId from storage.
  1656. *
  1657. * This method is protected by default in order to keep the public
  1658. * api reasonable. You can provide public methods for those you
  1659. * actually need in CcShowInstances.
  1660. *
  1661. * @param Criteria $criteria optional Criteria object to narrow the query
  1662. * @param PropelPDO $con optional connection object
  1663. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1664. * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
  1665. */
  1666. public function getCcShowInstancessRelatedByDbIdJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1667. {
  1668. $query = CcShowInstancesQuery::create(null, $criteria);
  1669. $query->joinWith('CcFiles', $join_behavior);
  1670. return $this->getCcShowInstancessRelatedByDbId($query, $con);
  1671. }
  1672. /**
  1673. * Clears out the collCcSchedules collection
  1674. *
  1675. * This does not modify the database; however, it will remove any associated objects, causing
  1676. * them to be refetched by subsequent calls to accessor method.
  1677. *
  1678. * @return void
  1679. * @see addCcSchedules()
  1680. */
  1681. public function clearCcSchedules()
  1682. {
  1683. $this->collCcSchedules = null; // important to set this to NULL since that means it is uninitialized
  1684. }
  1685. /**
  1686. * Initializes the collCcSchedules collection.
  1687. *
  1688. * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules());
  1689. * however, you may wish to override this method in your stub class to provide setting appropriate
  1690. * to your application -- for example, setting the initial array to the values stored in database.
  1691. *
  1692. * @return void
  1693. */
  1694. public function initCcSchedules()
  1695. {
  1696. $this->collCcSchedules = new PropelObjectCollection();
  1697. $this->collCcSchedules->setModel('CcSchedule');
  1698. }
  1699. /**
  1700. * Gets an array of CcSchedule objects which contain a foreign key that references this object.
  1701. *
  1702. * If the $criteria is not null, it is used to always fetch the results from the database.
  1703. * Otherwise the results are fetched from the database the first time, then cached.
  1704. * Next time the same method is called without $criteria, the cached collection is returned.
  1705. * If this CcShowInstances is new, it will return
  1706. * an empty collection or the current collection; the criteria is ignored on a new object.
  1707. *
  1708. * @param Criteria $criteria optional Criteria object to narrow the query
  1709. * @param PropelPDO $con optional connection object
  1710. * @return PropelCollection|array CcSchedule[] List of CcSchedule objects
  1711. * @throws PropelException
  1712. */
  1713. public function getCcSchedules($criteria = null, PropelPDO $con = null)
  1714. {
  1715. if(null === $this->collCcSchedules || null !== $criteria) {
  1716. if ($this->isNew() && null === $this->collCcSchedules) {
  1717. // return empty collection
  1718. $this->initCcSchedules();
  1719. } else {
  1720. $collCcSchedules = CcScheduleQuery::create(null, $criteria)
  1721. ->filterByCcShowInstances($this)
  1722. ->find($con);
  1723. if (null !== $criteria) {
  1724. return $collCcSchedules;
  1725. }
  1726. $this->collCcSchedules = $collCcSchedules;
  1727. }
  1728. }
  1729. return $this->collCcSchedules;
  1730. }
  1731. /**
  1732. * Returns the number of related CcSchedule objects.
  1733. *
  1734. * @param Criteria $criteria
  1735. * @param boolean $distinct
  1736. * @param PropelPDO $con
  1737. * @return int Count of related CcSchedule objects.
  1738. * @throws PropelException
  1739. */
  1740. public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1741. {
  1742. if(null === $this->collCcSchedules || null !== $criteria) {
  1743. if ($this->isNew() && null === $this->collCcSchedules) {
  1744. return 0;
  1745. } else {
  1746. $query = CcScheduleQuery::create(null, $criteria);
  1747. if($distinct) {
  1748. $query->distinct();
  1749. }
  1750. return $query
  1751. ->filterByCcShowInstances($this)
  1752. ->count($con);
  1753. }
  1754. } else {
  1755. return count($this->collCcSchedules);
  1756. }
  1757. }
  1758. /**
  1759. * Method called to associate a CcSchedule object to this object
  1760. * through the CcSchedule foreign key attribute.
  1761. *
  1762. * @param CcSchedule $l CcSchedule
  1763. * @return void
  1764. * @throws PropelException
  1765. */
  1766. public function addCcSchedule(CcSchedule $l)
  1767. {
  1768. if ($this->collCcSchedules === null) {
  1769. $this->initCcSchedules();
  1770. }
  1771. if (!$this->collCcSchedules->contains($l)) { // only add it if the **same** object is not already associated
  1772. $this->collCcSchedules[]= $l;
  1773. $l->setCcShowInstances($this);
  1774. }
  1775. }
  1776. /**
  1777. * If this collection has already been initialized with
  1778. * an identical criteria, it returns the collection.
  1779. * Otherwise if this CcShowInstances is new, it will return
  1780. * an empty collection; or if this CcShowInstances has previously
  1781. * been saved, it will retrieve related CcSchedules from storage.
  1782. *
  1783. * This method is protected by default in order to keep the public
  1784. * api reasonable. You can provide public methods for those you
  1785. * actually need in CcShowInstances.
  1786. *
  1787. * @param Criteria $criteria optional Criteria object to narrow the query
  1788. * @param PropelPDO $con optional connection object
  1789. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1790. * @return PropelCollection|array CcSchedule[] List of CcSchedule objects
  1791. */
  1792. public function getCcSchedulesJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1793. {
  1794. $query = CcScheduleQuery::create(null, $criteria);
  1795. $query->joinWith('CcFiles', $join_behavior);
  1796. return $this->getCcSchedules($query, $con);
  1797. }
  1798. /**
  1799. * If this collection has already been initialized with
  1800. * an identical criteria, it returns the collection.
  1801. * Otherwise if this CcShowInstances is new, it will return
  1802. * an empty collection; or if this CcShowInstances has previously
  1803. * been saved, it will retrieve related CcSchedules from storage.
  1804. *
  1805. * This method is protected by default in order to keep the public
  1806. * api reasonable. You can provide public methods for those you
  1807. * actually need in CcShowInstances.
  1808. *
  1809. * @param Criteria $criteria optional Criteria object to narrow the query
  1810. * @param PropelPDO $con optional connection object
  1811. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1812. * @return PropelCollection|array CcSchedule[] List of CcSchedule objects
  1813. */
  1814. public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1815. {
  1816. $query = CcScheduleQuery::create(null, $criteria);
  1817. $query->joinWith('CcWebstream', $join_behavior);
  1818. return $this->getCcSchedules($query, $con);
  1819. }
  1820. /**
  1821. * Clears out the collCcPlayoutHistorys collection
  1822. *
  1823. * This does not modify the database; however, it will remove any associated objects, causing
  1824. * them to be refetched by subsequent calls to accessor method.
  1825. *
  1826. * @return void
  1827. * @see addCcPlayoutHistorys()
  1828. */
  1829. public function clearCcPlayoutHistorys()
  1830. {
  1831. $this->collCcPlayoutHistorys = null; // important to set this to NULL since that means it is uninitialized
  1832. }
  1833. /**
  1834. * Initializes the collCcPlayoutHistorys collection.
  1835. *
  1836. * By default this just sets the collCcPlayoutHistorys collection to an empty array (like clearcollCcPlayoutHistorys());
  1837. * however, you may wish to override this method in your stub class to provide setting appropriate
  1838. * to your application -- for example, setting the initial array to the values stored in database.
  1839. *
  1840. * @return void
  1841. */
  1842. public function initCcPlayoutHistorys()
  1843. {
  1844. $this->collCcPlayoutHistorys = new PropelObjectCollection();
  1845. $this->collCcPlayoutHistorys->setModel('CcPlayoutHistory');
  1846. }
  1847. /**
  1848. * Gets an array of CcPlayoutHistory objects which contain a foreign key that references this object.
  1849. *
  1850. * If the $criteria is not null, it is used to always fetch the results from the database.
  1851. * Otherwise the results are fetched from the database the first time, then cached.
  1852. * Next time the same method is called without $criteria, the cached collection is returned.
  1853. * If this CcShowInstances is new, it will return
  1854. * an empty collection or the current collection; the criteria is ignored on a new object.
  1855. *
  1856. * @param Criteria $criteria optional Criteria object to narrow the query
  1857. * @param PropelPDO $con optional connection object
  1858. * @return PropelCollection|array CcPlayoutHistory[] List of CcPlayoutHistory objects
  1859. * @throws PropelException
  1860. */
  1861. public function getCcPlayoutHistorys($criteria = null, PropelPDO $con = null)
  1862. {
  1863. if(null === $this->collCcPlayoutHistorys || null !== $criteria) {
  1864. if ($this->isNew() && null === $this->collCcPlayoutHistorys) {
  1865. // return empty collection
  1866. $this->initCcPlayoutHistorys();
  1867. } else {
  1868. $collCcPlayoutHistorys = CcPlayoutHistoryQuery::create(null, $criteria)
  1869. ->filterByCcShowInstances($this)
  1870. ->find($con);
  1871. if (null !== $criteria) {
  1872. return $collCcPlayoutHistorys;
  1873. }
  1874. $this->collCcPlayoutHistorys = $collCcPlayoutHistorys;
  1875. }
  1876. }
  1877. return $this->collCcPlayoutHistorys;
  1878. }
  1879. /**
  1880. * Returns the number of related CcPlayoutHistory objects.
  1881. *
  1882. * @param Criteria $criteria
  1883. * @param boolean $distinct
  1884. * @param PropelPDO $con
  1885. * @return int Count of related CcPlayoutHistory objects.
  1886. * @throws PropelException
  1887. */
  1888. public function countCcPlayoutHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1889. {
  1890. if(null === $this->collCcPlayoutHistorys || null !== $criteria) {
  1891. if ($this->isNew() && null === $this->collCcPlayoutHistorys) {
  1892. return 0;
  1893. } else {
  1894. $query = CcPlayoutHistoryQuery::create(null, $criteria);
  1895. if($distinct) {
  1896. $query->distinct();
  1897. }
  1898. return $query
  1899. ->filterByCcShowInstances($this)
  1900. ->count($con);
  1901. }
  1902. } else {
  1903. return count($this->collCcPlayoutHistorys);
  1904. }
  1905. }
  1906. /**
  1907. * Method called to associate a CcPlayoutHistory object to this object
  1908. * through the CcPlayoutHistory foreign key attribute.
  1909. *
  1910. * @param CcPlayoutHistory $l CcPlayoutHistory
  1911. * @return void
  1912. * @throws PropelException
  1913. */
  1914. public function addCcPlayoutHistory(CcPlayoutHistory $l)
  1915. {
  1916. if ($this->collCcPlayoutHistorys === null) {
  1917. $this->initCcPlayoutHistorys();
  1918. }
  1919. if (!$this->collCcPlayoutHistorys->contains($l)) { // only add it if the **same** object is not already associated
  1920. $this->collCcPlayoutHistorys[]= $l;
  1921. $l->setCcShowInstances($this);
  1922. }
  1923. }
  1924. /**
  1925. * If this collection has already been initialized with
  1926. * an identical criteria, it returns the collection.
  1927. * Otherwise if this CcShowInstances is new, it will return
  1928. * an empty collection; or if this CcShowInstances has previously
  1929. * been saved, it will retrieve related CcPlayoutHistorys from storage.
  1930. *
  1931. * This method is protected by default in order to keep the public
  1932. * api reasonable. You can provide public methods for those you
  1933. * actually need in CcShowInstances.
  1934. *
  1935. * @param Criteria $criteria optional Criteria object to narrow the query
  1936. * @param PropelPDO $con optional connection object
  1937. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1938. * @return PropelCollection|array CcPlayoutHistory[] List of CcPlayoutHistory objects
  1939. */
  1940. public function getCcPlayoutHistorysJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1941. {
  1942. $query = CcPlayoutHistoryQuery::create(null, $criteria);
  1943. $query->joinWith('CcFiles', $join_behavior);
  1944. return $this->getCcPlayoutHistorys($query, $con);
  1945. }
  1946. /**
  1947. * Clears the current object and sets all attributes to their default values
  1948. */
  1949. public function clear()
  1950. {
  1951. $this->id = null;
  1952. $this->starts = null;
  1953. $this->ends = null;
  1954. $this->show_id = null;
  1955. $this->record = null;
  1956. $this->rebroadcast = null;
  1957. $this->instance_id = null;
  1958. $this->file_id = null;
  1959. $this->time_filled = null;
  1960. $this->created = null;
  1961. $this->last_scheduled = null;
  1962. $this->modified_instance = null;
  1963. $this->alreadyInSave = false;
  1964. $this->alreadyInValidation = false;
  1965. $this->clearAllReferences();
  1966. $this->applyDefaultValues();
  1967. $this->resetModified();
  1968. $this->setNew(true);
  1969. $this->setDeleted(false);
  1970. }
  1971. /**
  1972. * Resets all collections of referencing foreign keys.
  1973. *
  1974. * This method is a user-space workaround for PHP's inability to garbage collect objects
  1975. * with circular references. This is currently necessary when using Propel in certain
  1976. * daemon or large-volumne/high-memory operations.
  1977. *
  1978. * @param boolean $deep Whether to also clear the references on all associated objects.
  1979. */
  1980. public function clearAllReferences($deep = false)
  1981. {
  1982. if ($deep) {
  1983. if ($this->collCcShowInstancessRelatedByDbId) {
  1984. foreach ((array) $this->collCcShowInstancessRelatedByDbId as $o) {
  1985. $o->clearAllReferences($deep);
  1986. }
  1987. }
  1988. if ($this->collCcSchedules) {
  1989. foreach ((array) $this->collCcSchedules as $o) {
  1990. $o->clearAllReferences($deep);
  1991. }
  1992. }
  1993. if ($this->collCcPlayoutHistorys) {
  1994. foreach ((array) $this->collCcPlayoutHistorys as $o) {
  1995. $o->clearAllReferences($deep);
  1996. }
  1997. }
  1998. } // if ($deep)
  1999. $this->collCcShowInstancessRelatedByDbId = null;
  2000. $this->collCcSchedules = null;
  2001. $this->collCcPlayoutHistorys = null;
  2002. $this->aCcShow = null;
  2003. $this->aCcShowInstancesRelatedByDbOriginalShow = null;
  2004. $this->aCcFiles = null;
  2005. }
  2006. /**
  2007. * Catches calls to virtual methods
  2008. */
  2009. public function __call($name, $params)
  2010. {
  2011. if (preg_match('/get(\w+)/', $name, $matches)) {
  2012. $virtualColumn = $matches[1];
  2013. if ($this->hasVirtualColumn($virtualColumn)) {
  2014. return $this->getVirtualColumn($virtualColumn);
  2015. }
  2016. // no lcfirst in php<5.3...
  2017. $virtualColumn[0] = strtolower($virtualColumn[0]);
  2018. if ($this->hasVirtualColumn($virtualColumn)) {
  2019. return $this->getVirtualColumn($virtualColumn);
  2020. }
  2021. }
  2022. throw new PropelException('Call to undefined method: ' . $name);
  2023. }
  2024. } // BaseCcShowInstances