BaseCcBlock.php 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'cc_block' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcBlock extends BaseObject implements Persistent
  10. {
  11. /**
  12. * Peer class name
  13. */
  14. const PEER = 'CcBlockPeer';
  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 CcBlockPeer
  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 name field.
  29. * Note: this column has a database default value of: ''
  30. * @var string
  31. */
  32. protected $name;
  33. /**
  34. * The value for the mtime field.
  35. * @var string
  36. */
  37. protected $mtime;
  38. /**
  39. * The value for the utime field.
  40. * @var string
  41. */
  42. protected $utime;
  43. /**
  44. * The value for the creator_id field.
  45. * @var int
  46. */
  47. protected $creator_id;
  48. /**
  49. * The value for the description field.
  50. * @var string
  51. */
  52. protected $description;
  53. /**
  54. * The value for the length field.
  55. * Note: this column has a database default value of: '00:00:00'
  56. * @var string
  57. */
  58. protected $length;
  59. /**
  60. * The value for the type field.
  61. * Note: this column has a database default value of: 'static'
  62. * @var string
  63. */
  64. protected $type;
  65. /**
  66. * @var CcSubjs
  67. */
  68. protected $aCcSubjs;
  69. /**
  70. * @var array CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects.
  71. */
  72. protected $collCcPlaylistcontentss;
  73. /**
  74. * @var array CcBlockcontents[] Collection to store aggregation of CcBlockcontents objects.
  75. */
  76. protected $collCcBlockcontentss;
  77. /**
  78. * @var array CcBlockcriteria[] Collection to store aggregation of CcBlockcriteria objects.
  79. */
  80. protected $collCcBlockcriterias;
  81. /**
  82. * Flag to prevent endless save loop, if this object is referenced
  83. * by another object which falls in this transaction.
  84. * @var boolean
  85. */
  86. protected $alreadyInSave = false;
  87. /**
  88. * Flag to prevent endless validation loop, if this object is referenced
  89. * by another object which falls in this transaction.
  90. * @var boolean
  91. */
  92. protected $alreadyInValidation = false;
  93. /**
  94. * Applies default values to this object.
  95. * This method should be called from the object's constructor (or
  96. * equivalent initialization method).
  97. * @see __construct()
  98. */
  99. public function applyDefaultValues()
  100. {
  101. $this->name = '';
  102. $this->length = '00:00:00';
  103. $this->type = 'static';
  104. }
  105. /**
  106. * Initializes internal state of BaseCcBlock object.
  107. * @see applyDefaults()
  108. */
  109. public function __construct()
  110. {
  111. parent::__construct();
  112. $this->applyDefaultValues();
  113. }
  114. /**
  115. * Get the [id] column value.
  116. *
  117. * @return int
  118. */
  119. public function getDbId()
  120. {
  121. return $this->id;
  122. }
  123. /**
  124. * Get the [name] column value.
  125. *
  126. * @return string
  127. */
  128. public function getDbName()
  129. {
  130. return $this->name;
  131. }
  132. /**
  133. * Get the [optionally formatted] temporal [mtime] column value.
  134. *
  135. *
  136. * @param string $format The date/time format string (either date()-style or strftime()-style).
  137. * If format is NULL, then the raw DateTime object will be returned.
  138. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  139. * @throws PropelException - if unable to parse/validate the date/time value.
  140. */
  141. public function getDbMtime($format = 'Y-m-d H:i:s')
  142. {
  143. if ($this->mtime === null) {
  144. return null;
  145. }
  146. try {
  147. $dt = new DateTime($this->mtime);
  148. } catch (Exception $x) {
  149. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x);
  150. }
  151. if ($format === null) {
  152. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  153. return $dt;
  154. } elseif (strpos($format, '%') !== false) {
  155. return strftime($format, $dt->format('U'));
  156. } else {
  157. return $dt->format($format);
  158. }
  159. }
  160. /**
  161. * Get the [optionally formatted] temporal [utime] column value.
  162. *
  163. *
  164. * @param string $format The date/time format string (either date()-style or strftime()-style).
  165. * If format is NULL, then the raw DateTime object will be returned.
  166. * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  167. * @throws PropelException - if unable to parse/validate the date/time value.
  168. */
  169. public function getDbUtime($format = 'Y-m-d H:i:s')
  170. {
  171. if ($this->utime === null) {
  172. return null;
  173. }
  174. try {
  175. $dt = new DateTime($this->utime);
  176. } catch (Exception $x) {
  177. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x);
  178. }
  179. if ($format === null) {
  180. // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  181. return $dt;
  182. } elseif (strpos($format, '%') !== false) {
  183. return strftime($format, $dt->format('U'));
  184. } else {
  185. return $dt->format($format);
  186. }
  187. }
  188. /**
  189. * Get the [creator_id] column value.
  190. *
  191. * @return int
  192. */
  193. public function getDbCreatorId()
  194. {
  195. return $this->creator_id;
  196. }
  197. /**
  198. * Get the [description] column value.
  199. *
  200. * @return string
  201. */
  202. public function getDbDescription()
  203. {
  204. return $this->description;
  205. }
  206. /**
  207. * Get the [length] column value.
  208. *
  209. * @return string
  210. */
  211. public function getDbLength()
  212. {
  213. return $this->length;
  214. }
  215. /**
  216. * Get the [type] column value.
  217. *
  218. * @return string
  219. */
  220. public function getDbType()
  221. {
  222. return $this->type;
  223. }
  224. /**
  225. * Set the value of [id] column.
  226. *
  227. * @param int $v new value
  228. * @return CcBlock The current object (for fluent API support)
  229. */
  230. public function setDbId($v)
  231. {
  232. if ($v !== null) {
  233. $v = (int) $v;
  234. }
  235. if ($this->id !== $v) {
  236. $this->id = $v;
  237. $this->modifiedColumns[] = CcBlockPeer::ID;
  238. }
  239. return $this;
  240. } // setDbId()
  241. /**
  242. * Set the value of [name] column.
  243. *
  244. * @param string $v new value
  245. * @return CcBlock The current object (for fluent API support)
  246. */
  247. public function setDbName($v)
  248. {
  249. if ($v !== null) {
  250. $v = (string) $v;
  251. }
  252. if ($this->name !== $v || $this->isNew()) {
  253. $this->name = $v;
  254. $this->modifiedColumns[] = CcBlockPeer::NAME;
  255. }
  256. return $this;
  257. } // setDbName()
  258. /**
  259. * Sets the value of [mtime] column to a normalized version of the date/time value specified.
  260. *
  261. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  262. * be treated as NULL for temporal objects.
  263. * @return CcBlock The current object (for fluent API support)
  264. */
  265. public function setDbMtime($v)
  266. {
  267. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  268. // -- which is unexpected, to say the least.
  269. if ($v === null || $v === '') {
  270. $dt = null;
  271. } elseif ($v instanceof DateTime) {
  272. $dt = $v;
  273. } else {
  274. // some string/numeric value passed; we normalize that so that we can
  275. // validate it.
  276. try {
  277. if (is_numeric($v)) { // if it's a unix timestamp
  278. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  279. // We have to explicitly specify and then change the time zone because of a
  280. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  281. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  282. } else {
  283. $dt = new DateTime($v);
  284. }
  285. } catch (Exception $x) {
  286. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  287. }
  288. }
  289. if ( $this->mtime !== null || $dt !== null ) {
  290. // (nested ifs are a little easier to read in this case)
  291. $currNorm = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  292. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  293. if ( ($currNorm !== $newNorm) // normalized values don't match
  294. )
  295. {
  296. $this->mtime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  297. $this->modifiedColumns[] = CcBlockPeer::MTIME;
  298. }
  299. } // if either are not null
  300. return $this;
  301. } // setDbMtime()
  302. /**
  303. * Sets the value of [utime] column to a normalized version of the date/time value specified.
  304. *
  305. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  306. * be treated as NULL for temporal objects.
  307. * @return CcBlock The current object (for fluent API support)
  308. */
  309. public function setDbUtime($v)
  310. {
  311. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  312. // -- which is unexpected, to say the least.
  313. if ($v === null || $v === '') {
  314. $dt = null;
  315. } elseif ($v instanceof DateTime) {
  316. $dt = $v;
  317. } else {
  318. // some string/numeric value passed; we normalize that so that we can
  319. // validate it.
  320. try {
  321. if (is_numeric($v)) { // if it's a unix timestamp
  322. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  323. // We have to explicitly specify and then change the time zone because of a
  324. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  325. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  326. } else {
  327. $dt = new DateTime($v);
  328. }
  329. } catch (Exception $x) {
  330. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  331. }
  332. }
  333. if ( $this->utime !== null || $dt !== null ) {
  334. // (nested ifs are a little easier to read in this case)
  335. $currNorm = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
  336. $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
  337. if ( ($currNorm !== $newNorm) // normalized values don't match
  338. )
  339. {
  340. $this->utime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
  341. $this->modifiedColumns[] = CcBlockPeer::UTIME;
  342. }
  343. } // if either are not null
  344. return $this;
  345. } // setDbUtime()
  346. /**
  347. * Set the value of [creator_id] column.
  348. *
  349. * @param int $v new value
  350. * @return CcBlock The current object (for fluent API support)
  351. */
  352. public function setDbCreatorId($v)
  353. {
  354. if ($v !== null) {
  355. $v = (int) $v;
  356. }
  357. if ($this->creator_id !== $v) {
  358. $this->creator_id = $v;
  359. $this->modifiedColumns[] = CcBlockPeer::CREATOR_ID;
  360. }
  361. if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) {
  362. $this->aCcSubjs = null;
  363. }
  364. return $this;
  365. } // setDbCreatorId()
  366. /**
  367. * Set the value of [description] column.
  368. *
  369. * @param string $v new value
  370. * @return CcBlock The current object (for fluent API support)
  371. */
  372. public function setDbDescription($v)
  373. {
  374. if ($v !== null) {
  375. $v = (string) $v;
  376. }
  377. if ($this->description !== $v) {
  378. $this->description = $v;
  379. $this->modifiedColumns[] = CcBlockPeer::DESCRIPTION;
  380. }
  381. return $this;
  382. } // setDbDescription()
  383. /**
  384. * Set the value of [length] column.
  385. *
  386. * @param string $v new value
  387. * @return CcBlock The current object (for fluent API support)
  388. */
  389. public function setDbLength($v)
  390. {
  391. if ($v !== null) {
  392. $v = (string) $v;
  393. }
  394. if ($this->length !== $v || $this->isNew()) {
  395. $this->length = $v;
  396. $this->modifiedColumns[] = CcBlockPeer::LENGTH;
  397. }
  398. return $this;
  399. } // setDbLength()
  400. /**
  401. * Set the value of [type] column.
  402. *
  403. * @param string $v new value
  404. * @return CcBlock The current object (for fluent API support)
  405. */
  406. public function setDbType($v)
  407. {
  408. if ($v !== null) {
  409. $v = (string) $v;
  410. }
  411. if ($this->type !== $v || $this->isNew()) {
  412. $this->type = $v;
  413. $this->modifiedColumns[] = CcBlockPeer::TYPE;
  414. }
  415. return $this;
  416. } // setDbType()
  417. /**
  418. * Indicates whether the columns in this object are only set to default values.
  419. *
  420. * This method can be used in conjunction with isModified() to indicate whether an object is both
  421. * modified _and_ has some values set which are non-default.
  422. *
  423. * @return boolean Whether the columns in this object are only been set with default values.
  424. */
  425. public function hasOnlyDefaultValues()
  426. {
  427. if ($this->name !== '') {
  428. return false;
  429. }
  430. if ($this->length !== '00:00:00') {
  431. return false;
  432. }
  433. if ($this->type !== 'static') {
  434. return false;
  435. }
  436. // otherwise, everything was equal, so return TRUE
  437. return true;
  438. } // hasOnlyDefaultValues()
  439. /**
  440. * Hydrates (populates) the object variables with values from the database resultset.
  441. *
  442. * An offset (0-based "start column") is specified so that objects can be hydrated
  443. * with a subset of the columns in the resultset rows. This is needed, for example,
  444. * for results of JOIN queries where the resultset row includes columns from two or
  445. * more tables.
  446. *
  447. * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  448. * @param int $startcol 0-based offset column which indicates which restultset column to start with.
  449. * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
  450. * @return int next starting column
  451. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  452. */
  453. public function hydrate($row, $startcol = 0, $rehydrate = false)
  454. {
  455. try {
  456. $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
  457. $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
  458. $this->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
  459. $this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
  460. $this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
  461. $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
  462. $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
  463. $this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
  464. $this->resetModified();
  465. $this->setNew(false);
  466. if ($rehydrate) {
  467. $this->ensureConsistency();
  468. }
  469. return $startcol + 8; // 8 = CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS).
  470. } catch (Exception $e) {
  471. throw new PropelException("Error populating CcBlock object", $e);
  472. }
  473. }
  474. /**
  475. * Checks and repairs the internal consistency of the object.
  476. *
  477. * This method is executed after an already-instantiated object is re-hydrated
  478. * from the database. It exists to check any foreign keys to make sure that
  479. * the objects related to the current object are correct based on foreign key.
  480. *
  481. * You can override this method in the stub class, but you should always invoke
  482. * the base method from the overridden method (i.e. parent::ensureConsistency()),
  483. * in case your model changes.
  484. *
  485. * @throws PropelException
  486. */
  487. public function ensureConsistency()
  488. {
  489. if ($this->aCcSubjs !== null && $this->creator_id !== $this->aCcSubjs->getDbId()) {
  490. $this->aCcSubjs = null;
  491. }
  492. } // ensureConsistency
  493. /**
  494. * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  495. *
  496. * This will only work if the object has been saved and has a valid primary key set.
  497. *
  498. * @param boolean $deep (optional) Whether to also de-associated any related objects.
  499. * @param PropelPDO $con (optional) The PropelPDO connection to use.
  500. * @return void
  501. * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  502. */
  503. public function reload($deep = false, PropelPDO $con = null)
  504. {
  505. if ($this->isDeleted()) {
  506. throw new PropelException("Cannot reload a deleted object.");
  507. }
  508. if ($this->isNew()) {
  509. throw new PropelException("Cannot reload an unsaved object.");
  510. }
  511. if ($con === null) {
  512. $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  513. }
  514. // We don't need to alter the object instance pool; we're just modifying this instance
  515. // already in the pool.
  516. $stmt = CcBlockPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  517. $row = $stmt->fetch(PDO::FETCH_NUM);
  518. $stmt->closeCursor();
  519. if (!$row) {
  520. throw new PropelException('Cannot find matching row in the database to reload object values.');
  521. }
  522. $this->hydrate($row, 0, true); // rehydrate
  523. if ($deep) { // also de-associate any related objects?
  524. $this->aCcSubjs = null;
  525. $this->collCcPlaylistcontentss = null;
  526. $this->collCcBlockcontentss = null;
  527. $this->collCcBlockcriterias = null;
  528. } // if (deep)
  529. }
  530. /**
  531. * Removes this object from datastore and sets delete attribute.
  532. *
  533. * @param PropelPDO $con
  534. * @return void
  535. * @throws PropelException
  536. * @see BaseObject::setDeleted()
  537. * @see BaseObject::isDeleted()
  538. */
  539. public function delete(PropelPDO $con = null)
  540. {
  541. if ($this->isDeleted()) {
  542. throw new PropelException("This object has already been deleted.");
  543. }
  544. if ($con === null) {
  545. $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  546. }
  547. $con->beginTransaction();
  548. try {
  549. $ret = $this->preDelete($con);
  550. if ($ret) {
  551. CcBlockQuery::create()
  552. ->filterByPrimaryKey($this->getPrimaryKey())
  553. ->delete($con);
  554. $this->postDelete($con);
  555. $con->commit();
  556. $this->setDeleted(true);
  557. } else {
  558. $con->commit();
  559. }
  560. } catch (PropelException $e) {
  561. $con->rollBack();
  562. throw $e;
  563. }
  564. }
  565. /**
  566. * Persists this object to the database.
  567. *
  568. * If the object is new, it inserts it; otherwise an update is performed.
  569. * All modified related objects will also be persisted in the doSave()
  570. * method. This method wraps all precipitate database operations in a
  571. * single transaction.
  572. *
  573. * @param PropelPDO $con
  574. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  575. * @throws PropelException
  576. * @see doSave()
  577. */
  578. public function save(PropelPDO $con = null)
  579. {
  580. if ($this->isDeleted()) {
  581. throw new PropelException("You cannot save an object that has been deleted.");
  582. }
  583. if ($con === null) {
  584. $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  585. }
  586. $con->beginTransaction();
  587. $isInsert = $this->isNew();
  588. try {
  589. $ret = $this->preSave($con);
  590. if ($isInsert) {
  591. $ret = $ret && $this->preInsert($con);
  592. } else {
  593. $ret = $ret && $this->preUpdate($con);
  594. }
  595. if ($ret) {
  596. $affectedRows = $this->doSave($con);
  597. if ($isInsert) {
  598. $this->postInsert($con);
  599. } else {
  600. $this->postUpdate($con);
  601. }
  602. $this->postSave($con);
  603. CcBlockPeer::addInstanceToPool($this);
  604. } else {
  605. $affectedRows = 0;
  606. }
  607. $con->commit();
  608. return $affectedRows;
  609. } catch (PropelException $e) {
  610. $con->rollBack();
  611. throw $e;
  612. }
  613. }
  614. /**
  615. * Performs the work of inserting or updating the row in the database.
  616. *
  617. * If the object is new, it inserts it; otherwise an update is performed.
  618. * All related objects are also updated in this method.
  619. *
  620. * @param PropelPDO $con
  621. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  622. * @throws PropelException
  623. * @see save()
  624. */
  625. protected function doSave(PropelPDO $con)
  626. {
  627. $affectedRows = 0; // initialize var to track total num of affected rows
  628. if (!$this->alreadyInSave) {
  629. $this->alreadyInSave = true;
  630. // We call the save method on the following object(s) if they
  631. // were passed to this object by their coresponding set
  632. // method. This object relates to these object(s) by a
  633. // foreign key reference.
  634. if ($this->aCcSubjs !== null) {
  635. if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) {
  636. $affectedRows += $this->aCcSubjs->save($con);
  637. }
  638. $this->setCcSubjs($this->aCcSubjs);
  639. }
  640. if ($this->isNew() ) {
  641. $this->modifiedColumns[] = CcBlockPeer::ID;
  642. }
  643. // If this object has been modified, then save it to the database.
  644. if ($this->isModified()) {
  645. if ($this->isNew()) {
  646. $criteria = $this->buildCriteria();
  647. if ($criteria->keyContainsValue(CcBlockPeer::ID) ) {
  648. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockPeer::ID.')');
  649. }
  650. $pk = BasePeer::doInsert($criteria, $con);
  651. $affectedRows += 1;
  652. $this->setDbId($pk); //[IMV] update autoincrement primary key
  653. $this->setNew(false);
  654. } else {
  655. $affectedRows += CcBlockPeer::doUpdate($this, $con);
  656. }
  657. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  658. }
  659. if ($this->collCcPlaylistcontentss !== null) {
  660. foreach ($this->collCcPlaylistcontentss as $referrerFK) {
  661. if (!$referrerFK->isDeleted()) {
  662. $affectedRows += $referrerFK->save($con);
  663. }
  664. }
  665. }
  666. if ($this->collCcBlockcontentss !== null) {
  667. foreach ($this->collCcBlockcontentss as $referrerFK) {
  668. if (!$referrerFK->isDeleted()) {
  669. $affectedRows += $referrerFK->save($con);
  670. }
  671. }
  672. }
  673. if ($this->collCcBlockcriterias !== null) {
  674. foreach ($this->collCcBlockcriterias as $referrerFK) {
  675. if (!$referrerFK->isDeleted()) {
  676. $affectedRows += $referrerFK->save($con);
  677. }
  678. }
  679. }
  680. $this->alreadyInSave = false;
  681. }
  682. return $affectedRows;
  683. } // doSave()
  684. /**
  685. * Array of ValidationFailed objects.
  686. * @var array ValidationFailed[]
  687. */
  688. protected $validationFailures = array();
  689. /**
  690. * Gets any ValidationFailed objects that resulted from last call to validate().
  691. *
  692. *
  693. * @return array ValidationFailed[]
  694. * @see validate()
  695. */
  696. public function getValidationFailures()
  697. {
  698. return $this->validationFailures;
  699. }
  700. /**
  701. * Validates the objects modified field values and all objects related to this table.
  702. *
  703. * If $columns is either a column name or an array of column names
  704. * only those columns are validated.
  705. *
  706. * @param mixed $columns Column name or an array of column names.
  707. * @return boolean Whether all columns pass validation.
  708. * @see doValidate()
  709. * @see getValidationFailures()
  710. */
  711. public function validate($columns = null)
  712. {
  713. $res = $this->doValidate($columns);
  714. if ($res === true) {
  715. $this->validationFailures = array();
  716. return true;
  717. } else {
  718. $this->validationFailures = $res;
  719. return false;
  720. }
  721. }
  722. /**
  723. * This function performs the validation work for complex object models.
  724. *
  725. * In addition to checking the current object, all related objects will
  726. * also be validated. If all pass then <code>true</code> is returned; otherwise
  727. * an aggreagated array of ValidationFailed objects will be returned.
  728. *
  729. * @param array $columns Array of column names to validate.
  730. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  731. */
  732. protected function doValidate($columns = null)
  733. {
  734. if (!$this->alreadyInValidation) {
  735. $this->alreadyInValidation = true;
  736. $retval = null;
  737. $failureMap = array();
  738. // We call the validate method on the following object(s) if they
  739. // were passed to this object by their coresponding set
  740. // method. This object relates to these object(s) by a
  741. // foreign key reference.
  742. if ($this->aCcSubjs !== null) {
  743. if (!$this->aCcSubjs->validate($columns)) {
  744. $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures());
  745. }
  746. }
  747. if (($retval = CcBlockPeer::doValidate($this, $columns)) !== true) {
  748. $failureMap = array_merge($failureMap, $retval);
  749. }
  750. if ($this->collCcPlaylistcontentss !== null) {
  751. foreach ($this->collCcPlaylistcontentss as $referrerFK) {
  752. if (!$referrerFK->validate($columns)) {
  753. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  754. }
  755. }
  756. }
  757. if ($this->collCcBlockcontentss !== null) {
  758. foreach ($this->collCcBlockcontentss as $referrerFK) {
  759. if (!$referrerFK->validate($columns)) {
  760. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  761. }
  762. }
  763. }
  764. if ($this->collCcBlockcriterias !== null) {
  765. foreach ($this->collCcBlockcriterias as $referrerFK) {
  766. if (!$referrerFK->validate($columns)) {
  767. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  768. }
  769. }
  770. }
  771. $this->alreadyInValidation = false;
  772. }
  773. return (!empty($failureMap) ? $failureMap : true);
  774. }
  775. /**
  776. * Retrieves a field from the object by name passed in as a string.
  777. *
  778. * @param string $name name
  779. * @param string $type The type of fieldname the $name is of:
  780. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  781. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  782. * @return mixed Value of field.
  783. */
  784. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  785. {
  786. $pos = CcBlockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  787. $field = $this->getByPosition($pos);
  788. return $field;
  789. }
  790. /**
  791. * Retrieves a field from the object by Position as specified in the xml schema.
  792. * Zero-based.
  793. *
  794. * @param int $pos position in xml schema
  795. * @return mixed Value of field at $pos
  796. */
  797. public function getByPosition($pos)
  798. {
  799. switch($pos) {
  800. case 0:
  801. return $this->getDbId();
  802. break;
  803. case 1:
  804. return $this->getDbName();
  805. break;
  806. case 2:
  807. return $this->getDbMtime();
  808. break;
  809. case 3:
  810. return $this->getDbUtime();
  811. break;
  812. case 4:
  813. return $this->getDbCreatorId();
  814. break;
  815. case 5:
  816. return $this->getDbDescription();
  817. break;
  818. case 6:
  819. return $this->getDbLength();
  820. break;
  821. case 7:
  822. return $this->getDbType();
  823. break;
  824. default:
  825. return null;
  826. break;
  827. } // switch()
  828. }
  829. /**
  830. * Exports the object as an array.
  831. *
  832. * You can specify the key type of the array by passing one of the class
  833. * type constants.
  834. *
  835. * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  836. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  837. * Defaults to BasePeer::TYPE_PHPNAME.
  838. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  839. * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  840. *
  841. * @return array an associative array containing the field names (as keys) and field values
  842. */
  843. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false)
  844. {
  845. $keys = CcBlockPeer::getFieldNames($keyType);
  846. $result = array(
  847. $keys[0] => $this->getDbId(),
  848. $keys[1] => $this->getDbName(),
  849. $keys[2] => $this->getDbMtime(),
  850. $keys[3] => $this->getDbUtime(),
  851. $keys[4] => $this->getDbCreatorId(),
  852. $keys[5] => $this->getDbDescription(),
  853. $keys[6] => $this->getDbLength(),
  854. $keys[7] => $this->getDbType(),
  855. );
  856. if ($includeForeignObjects) {
  857. if (null !== $this->aCcSubjs) {
  858. $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, true);
  859. }
  860. }
  861. return $result;
  862. }
  863. /**
  864. * Sets a field from the object by name passed in as a string.
  865. *
  866. * @param string $name peer name
  867. * @param mixed $value field value
  868. * @param string $type The type of fieldname the $name is of:
  869. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  870. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  871. * @return void
  872. */
  873. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  874. {
  875. $pos = CcBlockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  876. return $this->setByPosition($pos, $value);
  877. }
  878. /**
  879. * Sets a field from the object by Position as specified in the xml schema.
  880. * Zero-based.
  881. *
  882. * @param int $pos position in xml schema
  883. * @param mixed $value field value
  884. * @return void
  885. */
  886. public function setByPosition($pos, $value)
  887. {
  888. switch($pos) {
  889. case 0:
  890. $this->setDbId($value);
  891. break;
  892. case 1:
  893. $this->setDbName($value);
  894. break;
  895. case 2:
  896. $this->setDbMtime($value);
  897. break;
  898. case 3:
  899. $this->setDbUtime($value);
  900. break;
  901. case 4:
  902. $this->setDbCreatorId($value);
  903. break;
  904. case 5:
  905. $this->setDbDescription($value);
  906. break;
  907. case 6:
  908. $this->setDbLength($value);
  909. break;
  910. case 7:
  911. $this->setDbType($value);
  912. break;
  913. } // switch()
  914. }
  915. /**
  916. * Populates the object using an array.
  917. *
  918. * This is particularly useful when populating an object from one of the
  919. * request arrays (e.g. $_POST). This method goes through the column
  920. * names, checking to see whether a matching key exists in populated
  921. * array. If so the setByName() method is called for that column.
  922. *
  923. * You can specify the key type of the array by additionally passing one
  924. * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  925. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  926. * The default key type is the column's phpname (e.g. 'AuthorId')
  927. *
  928. * @param array $arr An array to populate the object from.
  929. * @param string $keyType The type of keys the array uses.
  930. * @return void
  931. */
  932. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  933. {
  934. $keys = CcBlockPeer::getFieldNames($keyType);
  935. if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
  936. if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
  937. if (array_key_exists($keys[2], $arr)) $this->setDbMtime($arr[$keys[2]]);
  938. if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]);
  939. if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]);
  940. if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]);
  941. if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]);
  942. if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]);
  943. }
  944. /**
  945. * Build a Criteria object containing the values of all modified columns in this object.
  946. *
  947. * @return Criteria The Criteria object containing all modified values.
  948. */
  949. public function buildCriteria()
  950. {
  951. $criteria = new Criteria(CcBlockPeer::DATABASE_NAME);
  952. if ($this->isColumnModified(CcBlockPeer::ID)) $criteria->add(CcBlockPeer::ID, $this->id);
  953. if ($this->isColumnModified(CcBlockPeer::NAME)) $criteria->add(CcBlockPeer::NAME, $this->name);
  954. if ($this->isColumnModified(CcBlockPeer::MTIME)) $criteria->add(CcBlockPeer::MTIME, $this->mtime);
  955. if ($this->isColumnModified(CcBlockPeer::UTIME)) $criteria->add(CcBlockPeer::UTIME, $this->utime);
  956. if ($this->isColumnModified(CcBlockPeer::CREATOR_ID)) $criteria->add(CcBlockPeer::CREATOR_ID, $this->creator_id);
  957. if ($this->isColumnModified(CcBlockPeer::DESCRIPTION)) $criteria->add(CcBlockPeer::DESCRIPTION, $this->description);
  958. if ($this->isColumnModified(CcBlockPeer::LENGTH)) $criteria->add(CcBlockPeer::LENGTH, $this->length);
  959. if ($this->isColumnModified(CcBlockPeer::TYPE)) $criteria->add(CcBlockPeer::TYPE, $this->type);
  960. return $criteria;
  961. }
  962. /**
  963. * Builds a Criteria object containing the primary key for this object.
  964. *
  965. * Unlike buildCriteria() this method includes the primary key values regardless
  966. * of whether or not they have been modified.
  967. *
  968. * @return Criteria The Criteria object containing value(s) for primary key(s).
  969. */
  970. public function buildPkeyCriteria()
  971. {
  972. $criteria = new Criteria(CcBlockPeer::DATABASE_NAME);
  973. $criteria->add(CcBlockPeer::ID, $this->id);
  974. return $criteria;
  975. }
  976. /**
  977. * Returns the primary key for this object (row).
  978. * @return int
  979. */
  980. public function getPrimaryKey()
  981. {
  982. return $this->getDbId();
  983. }
  984. /**
  985. * Generic method to set the primary key (id column).
  986. *
  987. * @param int $key Primary key.
  988. * @return void
  989. */
  990. public function setPrimaryKey($key)
  991. {
  992. $this->setDbId($key);
  993. }
  994. /**
  995. * Returns true if the primary key for this object is null.
  996. * @return boolean
  997. */
  998. public function isPrimaryKeyNull()
  999. {
  1000. return null === $this->getDbId();
  1001. }
  1002. /**
  1003. * Sets contents of passed object to values from current object.
  1004. *
  1005. * If desired, this method can also make copies of all associated (fkey referrers)
  1006. * objects.
  1007. *
  1008. * @param object $copyObj An object of CcBlock (or compatible) type.
  1009. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1010. * @throws PropelException
  1011. */
  1012. public function copyInto($copyObj, $deepCopy = false)
  1013. {
  1014. $copyObj->setDbName($this->name);
  1015. $copyObj->setDbMtime($this->mtime);
  1016. $copyObj->setDbUtime($this->utime);
  1017. $copyObj->setDbCreatorId($this->creator_id);
  1018. $copyObj->setDbDescription($this->description);
  1019. $copyObj->setDbLength($this->length);
  1020. $copyObj->setDbType($this->type);
  1021. if ($deepCopy) {
  1022. // important: temporarily setNew(false) because this affects the behavior of
  1023. // the getter/setter methods for fkey referrer objects.
  1024. $copyObj->setNew(false);
  1025. foreach ($this->getCcPlaylistcontentss() as $relObj) {
  1026. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1027. $copyObj->addCcPlaylistcontents($relObj->copy($deepCopy));
  1028. }
  1029. }
  1030. foreach ($this->getCcBlockcontentss() as $relObj) {
  1031. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1032. $copyObj->addCcBlockcontents($relObj->copy($deepCopy));
  1033. }
  1034. }
  1035. foreach ($this->getCcBlockcriterias() as $relObj) {
  1036. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1037. $copyObj->addCcBlockcriteria($relObj->copy($deepCopy));
  1038. }
  1039. }
  1040. } // if ($deepCopy)
  1041. $copyObj->setNew(true);
  1042. $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
  1043. }
  1044. /**
  1045. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1046. * It creates a new object filling in the simple attributes, but skipping any primary
  1047. * keys that are defined for the table.
  1048. *
  1049. * If desired, this method can also make copies of all associated (fkey referrers)
  1050. * objects.
  1051. *
  1052. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1053. * @return CcBlock Clone of current object.
  1054. * @throws PropelException
  1055. */
  1056. public function copy($deepCopy = false)
  1057. {
  1058. // we use get_class(), because this might be a subclass
  1059. $clazz = get_class($this);
  1060. $copyObj = new $clazz();
  1061. $this->copyInto($copyObj, $deepCopy);
  1062. return $copyObj;
  1063. }
  1064. /**
  1065. * Returns a peer instance associated with this om.
  1066. *
  1067. * Since Peer classes are not to have any instance attributes, this method returns the
  1068. * same instance for all member of this class. The method could therefore
  1069. * be static, but this would prevent one from overriding the behavior.
  1070. *
  1071. * @return CcBlockPeer
  1072. */
  1073. public function getPeer()
  1074. {
  1075. if (self::$peer === null) {
  1076. self::$peer = new CcBlockPeer();
  1077. }
  1078. return self::$peer;
  1079. }
  1080. /**
  1081. * Declares an association between this object and a CcSubjs object.
  1082. *
  1083. * @param CcSubjs $v
  1084. * @return CcBlock The current object (for fluent API support)
  1085. * @throws PropelException
  1086. */
  1087. public function setCcSubjs(CcSubjs $v = null)
  1088. {
  1089. if ($v === null) {
  1090. $this->setDbCreatorId(NULL);
  1091. } else {
  1092. $this->setDbCreatorId($v->getDbId());
  1093. }
  1094. $this->aCcSubjs = $v;
  1095. // Add binding for other direction of this n:n relationship.
  1096. // If this object has already been added to the CcSubjs object, it will not be re-added.
  1097. if ($v !== null) {
  1098. $v->addCcBlock($this);
  1099. }
  1100. return $this;
  1101. }
  1102. /**
  1103. * Get the associated CcSubjs object
  1104. *
  1105. * @param PropelPDO Optional Connection object.
  1106. * @return CcSubjs The associated CcSubjs object.
  1107. * @throws PropelException
  1108. */
  1109. public function getCcSubjs(PropelPDO $con = null)
  1110. {
  1111. if ($this->aCcSubjs === null && ($this->creator_id !== null)) {
  1112. $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_id, $con);
  1113. /* The following can be used additionally to
  1114. guarantee the related object contains a reference
  1115. to this object. This level of coupling may, however, be
  1116. undesirable since it could result in an only partially populated collection
  1117. in the referenced object.
  1118. $this->aCcSubjs->addCcBlocks($this);
  1119. */
  1120. }
  1121. return $this->aCcSubjs;
  1122. }
  1123. /**
  1124. * Clears out the collCcPlaylistcontentss collection
  1125. *
  1126. * This does not modify the database; however, it will remove any associated objects, causing
  1127. * them to be refetched by subsequent calls to accessor method.
  1128. *
  1129. * @return void
  1130. * @see addCcPlaylistcontentss()
  1131. */
  1132. public function clearCcPlaylistcontentss()
  1133. {
  1134. $this->collCcPlaylistcontentss = null; // important to set this to NULL since that means it is uninitialized
  1135. }
  1136. /**
  1137. * Initializes the collCcPlaylistcontentss collection.
  1138. *
  1139. * By default this just sets the collCcPlaylistcontentss collection to an empty array (like clearcollCcPlaylistcontentss());
  1140. * however, you may wish to override this method in your stub class to provide setting appropriate
  1141. * to your application -- for example, setting the initial array to the values stored in database.
  1142. *
  1143. * @return void
  1144. */
  1145. public function initCcPlaylistcontentss()
  1146. {
  1147. $this->collCcPlaylistcontentss = new PropelObjectCollection();
  1148. $this->collCcPlaylistcontentss->setModel('CcPlaylistcontents');
  1149. }
  1150. /**
  1151. * Gets an array of CcPlaylistcontents objects which contain a foreign key that references this object.
  1152. *
  1153. * If the $criteria is not null, it is used to always fetch the results from the database.
  1154. * Otherwise the results are fetched from the database the first time, then cached.
  1155. * Next time the same method is called without $criteria, the cached collection is returned.
  1156. * If this CcBlock is new, it will return
  1157. * an empty collection or the current collection; the criteria is ignored on a new object.
  1158. *
  1159. * @param Criteria $criteria optional Criteria object to narrow the query
  1160. * @param PropelPDO $con optional connection object
  1161. * @return PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects
  1162. * @throws PropelException
  1163. */
  1164. public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null)
  1165. {
  1166. if(null === $this->collCcPlaylistcontentss || null !== $criteria) {
  1167. if ($this->isNew() && null === $this->collCcPlaylistcontentss) {
  1168. // return empty collection
  1169. $this->initCcPlaylistcontentss();
  1170. } else {
  1171. $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria)
  1172. ->filterByCcBlock($this)
  1173. ->find($con);
  1174. if (null !== $criteria) {
  1175. return $collCcPlaylistcontentss;
  1176. }
  1177. $this->collCcPlaylistcontentss = $collCcPlaylistcontentss;
  1178. }
  1179. }
  1180. return $this->collCcPlaylistcontentss;
  1181. }
  1182. /**
  1183. * Returns the number of related CcPlaylistcontents objects.
  1184. *
  1185. * @param Criteria $criteria
  1186. * @param boolean $distinct
  1187. * @param PropelPDO $con
  1188. * @return int Count of related CcPlaylistcontents objects.
  1189. * @throws PropelException
  1190. */
  1191. public function countCcPlaylistcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1192. {
  1193. if(null === $this->collCcPlaylistcontentss || null !== $criteria) {
  1194. if ($this->isNew() && null === $this->collCcPlaylistcontentss) {
  1195. return 0;
  1196. } else {
  1197. $query = CcPlaylistcontentsQuery::create(null, $criteria);
  1198. if($distinct) {
  1199. $query->distinct();
  1200. }
  1201. return $query
  1202. ->filterByCcBlock($this)
  1203. ->count($con);
  1204. }
  1205. } else {
  1206. return count($this->collCcPlaylistcontentss);
  1207. }
  1208. }
  1209. /**
  1210. * Method called to associate a CcPlaylistcontents object to this object
  1211. * through the CcPlaylistcontents foreign key attribute.
  1212. *
  1213. * @param CcPlaylistcontents $l CcPlaylistcontents
  1214. * @return void
  1215. * @throws PropelException
  1216. */
  1217. public function addCcPlaylistcontents(CcPlaylistcontents $l)
  1218. {
  1219. if ($this->collCcPlaylistcontentss === null) {
  1220. $this->initCcPlaylistcontentss();
  1221. }
  1222. if (!$this->collCcPlaylistcontentss->contains($l)) { // only add it if the **same** object is not already associated
  1223. $this->collCcPlaylistcontentss[]= $l;
  1224. $l->setCcBlock($this);
  1225. }
  1226. }
  1227. /**
  1228. * If this collection has already been initialized with
  1229. * an identical criteria, it returns the collection.
  1230. * Otherwise if this CcBlock is new, it will return
  1231. * an empty collection; or if this CcBlock has previously
  1232. * been saved, it will retrieve related CcPlaylistcontentss from storage.
  1233. *
  1234. * This method is protected by default in order to keep the public
  1235. * api reasonable. You can provide public methods for those you
  1236. * actually need in CcBlock.
  1237. *
  1238. * @param Criteria $criteria optional Criteria object to narrow the query
  1239. * @param PropelPDO $con optional connection object
  1240. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1241. * @return PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects
  1242. */
  1243. public function getCcPlaylistcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1244. {
  1245. $query = CcPlaylistcontentsQuery::create(null, $criteria);
  1246. $query->joinWith('CcFiles', $join_behavior);
  1247. return $this->getCcPlaylistcontentss($query, $con);
  1248. }
  1249. /**
  1250. * If this collection has already been initialized with
  1251. * an identical criteria, it returns the collection.
  1252. * Otherwise if this CcBlock is new, it will return
  1253. * an empty collection; or if this CcBlock has previously
  1254. * been saved, it will retrieve related CcPlaylistcontentss from storage.
  1255. *
  1256. * This method is protected by default in order to keep the public
  1257. * api reasonable. You can provide public methods for those you
  1258. * actually need in CcBlock.
  1259. *
  1260. * @param Criteria $criteria optional Criteria object to narrow the query
  1261. * @param PropelPDO $con optional connection object
  1262. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1263. * @return PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects
  1264. */
  1265. public function getCcPlaylistcontentssJoinCcPlaylist($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1266. {
  1267. $query = CcPlaylistcontentsQuery::create(null, $criteria);
  1268. $query->joinWith('CcPlaylist', $join_behavior);
  1269. return $this->getCcPlaylistcontentss($query, $con);
  1270. }
  1271. /**
  1272. * Clears out the collCcBlockcontentss collection
  1273. *
  1274. * This does not modify the database; however, it will remove any associated objects, causing
  1275. * them to be refetched by subsequent calls to accessor method.
  1276. *
  1277. * @return void
  1278. * @see addCcBlockcontentss()
  1279. */
  1280. public function clearCcBlockcontentss()
  1281. {
  1282. $this->collCcBlockcontentss = null; // important to set this to NULL since that means it is uninitialized
  1283. }
  1284. /**
  1285. * Initializes the collCcBlockcontentss collection.
  1286. *
  1287. * By default this just sets the collCcBlockcontentss collection to an empty array (like clearcollCcBlockcontentss());
  1288. * however, you may wish to override this method in your stub class to provide setting appropriate
  1289. * to your application -- for example, setting the initial array to the values stored in database.
  1290. *
  1291. * @return void
  1292. */
  1293. public function initCcBlockcontentss()
  1294. {
  1295. $this->collCcBlockcontentss = new PropelObjectCollection();
  1296. $this->collCcBlockcontentss->setModel('CcBlockcontents');
  1297. }
  1298. /**
  1299. * Gets an array of CcBlockcontents objects which contain a foreign key that references this object.
  1300. *
  1301. * If the $criteria is not null, it is used to always fetch the results from the database.
  1302. * Otherwise the results are fetched from the database the first time, then cached.
  1303. * Next time the same method is called without $criteria, the cached collection is returned.
  1304. * If this CcBlock is new, it will return
  1305. * an empty collection or the current collection; the criteria is ignored on a new object.
  1306. *
  1307. * @param Criteria $criteria optional Criteria object to narrow the query
  1308. * @param PropelPDO $con optional connection object
  1309. * @return PropelCollection|array CcBlockcontents[] List of CcBlockcontents objects
  1310. * @throws PropelException
  1311. */
  1312. public function getCcBlockcontentss($criteria = null, PropelPDO $con = null)
  1313. {
  1314. if(null === $this->collCcBlockcontentss || null !== $criteria) {
  1315. if ($this->isNew() && null === $this->collCcBlockcontentss) {
  1316. // return empty collection
  1317. $this->initCcBlockcontentss();
  1318. } else {
  1319. $collCcBlockcontentss = CcBlockcontentsQuery::create(null, $criteria)
  1320. ->filterByCcBlock($this)
  1321. ->find($con);
  1322. if (null !== $criteria) {
  1323. return $collCcBlockcontentss;
  1324. }
  1325. $this->collCcBlockcontentss = $collCcBlockcontentss;
  1326. }
  1327. }
  1328. return $this->collCcBlockcontentss;
  1329. }
  1330. /**
  1331. * Returns the number of related CcBlockcontents objects.
  1332. *
  1333. * @param Criteria $criteria
  1334. * @param boolean $distinct
  1335. * @param PropelPDO $con
  1336. * @return int Count of related CcBlockcontents objects.
  1337. * @throws PropelException
  1338. */
  1339. public function countCcBlockcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1340. {
  1341. if(null === $this->collCcBlockcontentss || null !== $criteria) {
  1342. if ($this->isNew() && null === $this->collCcBlockcontentss) {
  1343. return 0;
  1344. } else {
  1345. $query = CcBlockcontentsQuery::create(null, $criteria);
  1346. if($distinct) {
  1347. $query->distinct();
  1348. }
  1349. return $query
  1350. ->filterByCcBlock($this)
  1351. ->count($con);
  1352. }
  1353. } else {
  1354. return count($this->collCcBlockcontentss);
  1355. }
  1356. }
  1357. /**
  1358. * Method called to associate a CcBlockcontents object to this object
  1359. * through the CcBlockcontents foreign key attribute.
  1360. *
  1361. * @param CcBlockcontents $l CcBlockcontents
  1362. * @return void
  1363. * @throws PropelException
  1364. */
  1365. public function addCcBlockcontents(CcBlockcontents $l)
  1366. {
  1367. if ($this->collCcBlockcontentss === null) {
  1368. $this->initCcBlockcontentss();
  1369. }
  1370. if (!$this->collCcBlockcontentss->contains($l)) { // only add it if the **same** object is not already associated
  1371. $this->collCcBlockcontentss[]= $l;
  1372. $l->setCcBlock($this);
  1373. }
  1374. }
  1375. /**
  1376. * If this collection has already been initialized with
  1377. * an identical criteria, it returns the collection.
  1378. * Otherwise if this CcBlock is new, it will return
  1379. * an empty collection; or if this CcBlock has previously
  1380. * been saved, it will retrieve related CcBlockcontentss from storage.
  1381. *
  1382. * This method is protected by default in order to keep the public
  1383. * api reasonable. You can provide public methods for those you
  1384. * actually need in CcBlock.
  1385. *
  1386. * @param Criteria $criteria optional Criteria object to narrow the query
  1387. * @param PropelPDO $con optional connection object
  1388. * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  1389. * @return PropelCollection|array CcBlockcontents[] List of CcBlockcontents objects
  1390. */
  1391. public function getCcBlockcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1392. {
  1393. $query = CcBlockcontentsQuery::create(null, $criteria);
  1394. $query->joinWith('CcFiles', $join_behavior);
  1395. return $this->getCcBlockcontentss($query, $con);
  1396. }
  1397. /**
  1398. * Clears out the collCcBlockcriterias collection
  1399. *
  1400. * This does not modify the database; however, it will remove any associated objects, causing
  1401. * them to be refetched by subsequent calls to accessor method.
  1402. *
  1403. * @return void
  1404. * @see addCcBlockcriterias()
  1405. */
  1406. public function clearCcBlockcriterias()
  1407. {
  1408. $this->collCcBlockcriterias = null; // important to set this to NULL since that means it is uninitialized
  1409. }
  1410. /**
  1411. * Initializes the collCcBlockcriterias collection.
  1412. *
  1413. * By default this just sets the collCcBlockcriterias collection to an empty array (like clearcollCcBlockcriterias());
  1414. * however, you may wish to override this method in your stub class to provide setting appropriate
  1415. * to your application -- for example, setting the initial array to the values stored in database.
  1416. *
  1417. * @return void
  1418. */
  1419. public function initCcBlockcriterias()
  1420. {
  1421. $this->collCcBlockcriterias = new PropelObjectCollection();
  1422. $this->collCcBlockcriterias->setModel('CcBlockcriteria');
  1423. }
  1424. /**
  1425. * Gets an array of CcBlockcriteria objects which contain a foreign key that references this object.
  1426. *
  1427. * If the $criteria is not null, it is used to always fetch the results from the database.
  1428. * Otherwise the results are fetched from the database the first time, then cached.
  1429. * Next time the same method is called without $criteria, the cached collection is returned.
  1430. * If this CcBlock is new, it will return
  1431. * an empty collection or the current collection; the criteria is ignored on a new object.
  1432. *
  1433. * @param Criteria $criteria optional Criteria object to narrow the query
  1434. * @param PropelPDO $con optional connection object
  1435. * @return PropelCollection|array CcBlockcriteria[] List of CcBlockcriteria objects
  1436. * @throws PropelException
  1437. */
  1438. public function getCcBlockcriterias($criteria = null, PropelPDO $con = null)
  1439. {
  1440. if(null === $this->collCcBlockcriterias || null !== $criteria) {
  1441. if ($this->isNew() && null === $this->collCcBlockcriterias) {
  1442. // return empty collection
  1443. $this->initCcBlockcriterias();
  1444. } else {
  1445. $collCcBlockcriterias = CcBlockcriteriaQuery::create(null, $criteria)
  1446. ->filterByCcBlock($this)
  1447. ->find($con);
  1448. if (null !== $criteria) {
  1449. return $collCcBlockcriterias;
  1450. }
  1451. $this->collCcBlockcriterias = $collCcBlockcriterias;
  1452. }
  1453. }
  1454. return $this->collCcBlockcriterias;
  1455. }
  1456. /**
  1457. * Returns the number of related CcBlockcriteria objects.
  1458. *
  1459. * @param Criteria $criteria
  1460. * @param boolean $distinct
  1461. * @param PropelPDO $con
  1462. * @return int Count of related CcBlockcriteria objects.
  1463. * @throws PropelException
  1464. */
  1465. public function countCcBlockcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1466. {
  1467. if(null === $this->collCcBlockcriterias || null !== $criteria) {
  1468. if ($this->isNew() && null === $this->collCcBlockcriterias) {
  1469. return 0;
  1470. } else {
  1471. $query = CcBlockcriteriaQuery::create(null, $criteria);
  1472. if($distinct) {
  1473. $query->distinct();
  1474. }
  1475. return $query
  1476. ->filterByCcBlock($this)
  1477. ->count($con);
  1478. }
  1479. } else {
  1480. return count($this->collCcBlockcriterias);
  1481. }
  1482. }
  1483. /**
  1484. * Method called to associate a CcBlockcriteria object to this object
  1485. * through the CcBlockcriteria foreign key attribute.
  1486. *
  1487. * @param CcBlockcriteria $l CcBlockcriteria
  1488. * @return void
  1489. * @throws PropelException
  1490. */
  1491. public function addCcBlockcriteria(CcBlockcriteria $l)
  1492. {
  1493. if ($this->collCcBlockcriterias === null) {
  1494. $this->initCcBlockcriterias();
  1495. }
  1496. if (!$this->collCcBlockcriterias->contains($l)) { // only add it if the **same** object is not already associated
  1497. $this->collCcBlockcriterias[]= $l;
  1498. $l->setCcBlock($this);
  1499. }
  1500. }
  1501. /**
  1502. * Clears the current object and sets all attributes to their default values
  1503. */
  1504. public function clear()
  1505. {
  1506. $this->id = null;
  1507. $this->name = null;
  1508. $this->mtime = null;
  1509. $this->utime = null;
  1510. $this->creator_id = null;
  1511. $this->description = null;
  1512. $this->length = null;
  1513. $this->type = null;
  1514. $this->alreadyInSave = false;
  1515. $this->alreadyInValidation = false;
  1516. $this->clearAllReferences();
  1517. $this->applyDefaultValues();
  1518. $this->resetModified();
  1519. $this->setNew(true);
  1520. $this->setDeleted(false);
  1521. }
  1522. /**
  1523. * Resets all collections of referencing foreign keys.
  1524. *
  1525. * This method is a user-space workaround for PHP's inability to garbage collect objects
  1526. * with circular references. This is currently necessary when using Propel in certain
  1527. * daemon or large-volumne/high-memory operations.
  1528. *
  1529. * @param boolean $deep Whether to also clear the references on all associated objects.
  1530. */
  1531. public function clearAllReferences($deep = false)
  1532. {
  1533. if ($deep) {
  1534. if ($this->collCcPlaylistcontentss) {
  1535. foreach ((array) $this->collCcPlaylistcontentss as $o) {
  1536. $o->clearAllReferences($deep);
  1537. }
  1538. }
  1539. if ($this->collCcBlockcontentss) {
  1540. foreach ((array) $this->collCcBlockcontentss as $o) {
  1541. $o->clearAllReferences($deep);
  1542. }
  1543. }
  1544. if ($this->collCcBlockcriterias) {
  1545. foreach ((array) $this->collCcBlockcriterias as $o) {
  1546. $o->clearAllReferences($deep);
  1547. }
  1548. }
  1549. } // if ($deep)
  1550. $this->collCcPlaylistcontentss = null;
  1551. $this->collCcBlockcontentss = null;
  1552. $this->collCcBlockcriterias = null;
  1553. $this->aCcSubjs = null;
  1554. }
  1555. // aggregate_column behavior
  1556. /**
  1557. * Computes the value of the aggregate column length
  1558. *
  1559. * @param PropelPDO $con A connection object
  1560. *
  1561. * @return mixed The scalar result from the aggregate query
  1562. */
  1563. public function computeDbLength(PropelPDO $con)
  1564. {
  1565. $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.BLOCK_ID = :p1');
  1566. $stmt->bindValue(':p1', $this->getDbId());
  1567. $stmt->execute();
  1568. return $stmt->fetchColumn();
  1569. }
  1570. /**
  1571. * Updates the aggregate column length
  1572. *
  1573. * @param PropelPDO $con A connection object
  1574. */
  1575. public function updateDbLength(PropelPDO $con)
  1576. {
  1577. $this->setDbLength($this->computeDbLength($con));
  1578. $this->save($con);
  1579. }
  1580. /**
  1581. * Catches calls to virtual methods
  1582. */
  1583. public function __call($name, $params)
  1584. {
  1585. if (preg_match('/get(\w+)/', $name, $matches)) {
  1586. $virtualColumn = $matches[1];
  1587. if ($this->hasVirtualColumn($virtualColumn)) {
  1588. return $this->getVirtualColumn($virtualColumn);
  1589. }
  1590. // no lcfirst in php<5.3...
  1591. $virtualColumn[0] = strtolower($virtualColumn[0]);
  1592. if ($this->hasVirtualColumn($virtualColumn)) {
  1593. return $this->getVirtualColumn($virtualColumn);
  1594. }
  1595. }
  1596. throw new PropelException('Call to undefined method: ' . $name);
  1597. }
  1598. } // BaseCcBlock