PageRenderTime 43ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 1ms

/package/app/app/alpha/lib/model/om/Baseasset.php

https://bitbucket.org/pandaos/kaltura
PHP | 2921 lines | 1525 code | 388 blank | 1008 comment | 307 complexity | afeb21db98eb2b2ed05e920a2fab0c44 MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-3.0, JSON, MPL-2.0-no-copyleft-exception, Apache-2.0
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'flavor_asset' table.
  4. *
  5. *
  6. *
  7. * @package Core
  8. * @subpackage model.om
  9. */
  10. abstract class Baseasset extends BaseObject implements Persistent {
  11. /**
  12. * The Peer class.
  13. * Instance provides a convenient way of calling static methods on a class
  14. * that calling code may not be able to identify.
  15. * @var assetPeer
  16. */
  17. protected static $peer;
  18. /**
  19. * The value for the id field.
  20. * @var string
  21. */
  22. protected $id;
  23. /**
  24. * The value for the int_id field.
  25. * @var int
  26. */
  27. protected $int_id;
  28. /**
  29. * The value for the partner_id field.
  30. * @var int
  31. */
  32. protected $partner_id;
  33. /**
  34. * The value for the tags field.
  35. * @var string
  36. */
  37. protected $tags;
  38. /**
  39. * The value for the created_at field.
  40. * @var string
  41. */
  42. protected $created_at;
  43. /**
  44. * The value for the updated_at field.
  45. * @var string
  46. */
  47. protected $updated_at;
  48. /**
  49. * The value for the deleted_at field.
  50. * @var string
  51. */
  52. protected $deleted_at;
  53. /**
  54. * The value for the entry_id field.
  55. * @var string
  56. */
  57. protected $entry_id;
  58. /**
  59. * The value for the flavor_params_id field.
  60. * @var int
  61. */
  62. protected $flavor_params_id;
  63. /**
  64. * The value for the status field.
  65. * @var int
  66. */
  67. protected $status;
  68. /**
  69. * The value for the version field.
  70. * @var string
  71. */
  72. protected $version;
  73. /**
  74. * The value for the description field.
  75. * @var string
  76. */
  77. protected $description;
  78. /**
  79. * The value for the width field.
  80. * Note: this column has a database default value of: 0
  81. * @var int
  82. */
  83. protected $width;
  84. /**
  85. * The value for the height field.
  86. * Note: this column has a database default value of: 0
  87. * @var int
  88. */
  89. protected $height;
  90. /**
  91. * The value for the bitrate field.
  92. * Note: this column has a database default value of: 0
  93. * @var int
  94. */
  95. protected $bitrate;
  96. /**
  97. * The value for the frame_rate field.
  98. * Note: this column has a database default value of: 0
  99. * @var double
  100. */
  101. protected $frame_rate;
  102. /**
  103. * The value for the size field.
  104. * Note: this column has a database default value of: 0
  105. * @var int
  106. */
  107. protected $size;
  108. /**
  109. * The value for the is_original field.
  110. * Note: this column has a database default value of: false
  111. * @var boolean
  112. */
  113. protected $is_original;
  114. /**
  115. * The value for the file_ext field.
  116. * @var string
  117. */
  118. protected $file_ext;
  119. /**
  120. * The value for the container_format field.
  121. * @var string
  122. */
  123. protected $container_format;
  124. /**
  125. * The value for the video_codec_id field.
  126. * @var string
  127. */
  128. protected $video_codec_id;
  129. /**
  130. * The value for the type field.
  131. * Note: this column has a database default value of: 0
  132. * @var int
  133. */
  134. protected $type;
  135. /**
  136. * The value for the custom_data field.
  137. * @var string
  138. */
  139. protected $custom_data;
  140. /**
  141. * @var entry
  142. */
  143. protected $aentry;
  144. /**
  145. * @var assetParams
  146. */
  147. protected $aassetParams;
  148. /**
  149. * @var array mediaInfo[] Collection to store aggregation of mediaInfo objects.
  150. */
  151. protected $collmediaInfos;
  152. /**
  153. * @var Criteria The criteria used to select the current contents of collmediaInfos.
  154. */
  155. private $lastmediaInfoCriteria = null;
  156. /**
  157. * @var array assetParamsOutput[] Collection to store aggregation of assetParamsOutput objects.
  158. */
  159. protected $collassetParamsOutputs;
  160. /**
  161. * @var Criteria The criteria used to select the current contents of collassetParamsOutputs.
  162. */
  163. private $lastassetParamsOutputCriteria = null;
  164. /**
  165. * Flag to prevent endless save loop, if this object is referenced
  166. * by another object which falls in this transaction.
  167. * @var boolean
  168. */
  169. protected $alreadyInSave = false;
  170. /**
  171. * Flag to prevent endless validation loop, if this object is referenced
  172. * by another object which falls in this transaction.
  173. * @var boolean
  174. */
  175. protected $alreadyInValidation = false;
  176. /**
  177. * Store columns old values before the changes
  178. * @var array
  179. */
  180. protected $oldColumnsValues = array();
  181. /**
  182. * @return array
  183. */
  184. public function getColumnsOldValues()
  185. {
  186. return $this->oldColumnsValues;
  187. }
  188. /**
  189. * Applies default values to this object.
  190. * This method should be called from the object's constructor (or
  191. * equivalent initialization method).
  192. * @see __construct()
  193. */
  194. public function applyDefaultValues()
  195. {
  196. $this->width = 0;
  197. $this->height = 0;
  198. $this->bitrate = 0;
  199. $this->frame_rate = 0;
  200. $this->size = 0;
  201. $this->is_original = false;
  202. $this->type = 0;
  203. }
  204. /**
  205. * Initializes internal state of Baseasset object.
  206. * @see applyDefaults()
  207. */
  208. public function __construct()
  209. {
  210. parent::__construct();
  211. $this->applyDefaultValues();
  212. }
  213. /**
  214. * Get the [id] column value.
  215. *
  216. * @return string
  217. */
  218. public function getId()
  219. {
  220. return $this->id;
  221. }
  222. /**
  223. * Get the [int_id] column value.
  224. *
  225. * @return int
  226. */
  227. public function getIntId()
  228. {
  229. return $this->int_id;
  230. }
  231. /**
  232. * Get the [partner_id] column value.
  233. *
  234. * @return int
  235. */
  236. public function getPartnerId()
  237. {
  238. return $this->partner_id;
  239. }
  240. /**
  241. * Get the [tags] column value.
  242. *
  243. * @return string
  244. */
  245. public function getTags()
  246. {
  247. return $this->tags;
  248. }
  249. /**
  250. * Get the [optionally formatted] temporal [created_at] column value.
  251. *
  252. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  253. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  254. *
  255. * @param string $format The date/time format string (either date()-style or strftime()-style).
  256. * If format is NULL, then the raw unix timestamp integer will be returned.
  257. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  258. * @throws PropelException - if unable to parse/validate the date/time value.
  259. */
  260. public function getCreatedAt($format = 'Y-m-d H:i:s')
  261. {
  262. if ($this->created_at === null) {
  263. return null;
  264. }
  265. if ($this->created_at === '0000-00-00 00:00:00') {
  266. // while technically this is not a default value of NULL,
  267. // this seems to be closest in meaning.
  268. return null;
  269. } else {
  270. try {
  271. $dt = new DateTime($this->created_at);
  272. } catch (Exception $x) {
  273. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
  274. }
  275. }
  276. if ($format === null) {
  277. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  278. return (int) $dt->format('U');
  279. } elseif (strpos($format, '%') !== false) {
  280. return strftime($format, $dt->format('U'));
  281. } else {
  282. return $dt->format($format);
  283. }
  284. }
  285. /**
  286. * Get the [optionally formatted] temporal [updated_at] column value.
  287. *
  288. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  289. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  290. *
  291. * @param string $format The date/time format string (either date()-style or strftime()-style).
  292. * If format is NULL, then the raw unix timestamp integer will be returned.
  293. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  294. * @throws PropelException - if unable to parse/validate the date/time value.
  295. */
  296. public function getUpdatedAt($format = 'Y-m-d H:i:s')
  297. {
  298. if ($this->updated_at === null) {
  299. return null;
  300. }
  301. if ($this->updated_at === '0000-00-00 00:00:00') {
  302. // while technically this is not a default value of NULL,
  303. // this seems to be closest in meaning.
  304. return null;
  305. } else {
  306. try {
  307. $dt = new DateTime($this->updated_at);
  308. } catch (Exception $x) {
  309. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
  310. }
  311. }
  312. if ($format === null) {
  313. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  314. return (int) $dt->format('U');
  315. } elseif (strpos($format, '%') !== false) {
  316. return strftime($format, $dt->format('U'));
  317. } else {
  318. return $dt->format($format);
  319. }
  320. }
  321. /**
  322. * Get the [optionally formatted] temporal [deleted_at] column value.
  323. *
  324. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  325. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  326. *
  327. * @param string $format The date/time format string (either date()-style or strftime()-style).
  328. * If format is NULL, then the raw unix timestamp integer will be returned.
  329. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  330. * @throws PropelException - if unable to parse/validate the date/time value.
  331. */
  332. public function getDeletedAt($format = 'Y-m-d H:i:s')
  333. {
  334. if ($this->deleted_at === null) {
  335. return null;
  336. }
  337. if ($this->deleted_at === '0000-00-00 00:00:00') {
  338. // while technically this is not a default value of NULL,
  339. // this seems to be closest in meaning.
  340. return null;
  341. } else {
  342. try {
  343. $dt = new DateTime($this->deleted_at);
  344. } catch (Exception $x) {
  345. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->deleted_at, true), $x);
  346. }
  347. }
  348. if ($format === null) {
  349. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  350. return (int) $dt->format('U');
  351. } elseif (strpos($format, '%') !== false) {
  352. return strftime($format, $dt->format('U'));
  353. } else {
  354. return $dt->format($format);
  355. }
  356. }
  357. /**
  358. * Get the [entry_id] column value.
  359. *
  360. * @return string
  361. */
  362. public function getEntryId()
  363. {
  364. return $this->entry_id;
  365. }
  366. /**
  367. * Get the [flavor_params_id] column value.
  368. *
  369. * @return int
  370. */
  371. public function getFlavorParamsId()
  372. {
  373. return $this->flavor_params_id;
  374. }
  375. /**
  376. * Get the [status] column value.
  377. *
  378. * @return int
  379. */
  380. public function getStatus()
  381. {
  382. return $this->status;
  383. }
  384. /**
  385. * Get the [version] column value.
  386. *
  387. * @return string
  388. */
  389. public function getVersion()
  390. {
  391. return $this->version;
  392. }
  393. /**
  394. * Get the [description] column value.
  395. *
  396. * @return string
  397. */
  398. public function getDescription()
  399. {
  400. return $this->description;
  401. }
  402. /**
  403. * Get the [width] column value.
  404. *
  405. * @return int
  406. */
  407. public function getWidth()
  408. {
  409. return $this->width;
  410. }
  411. /**
  412. * Get the [height] column value.
  413. *
  414. * @return int
  415. */
  416. public function getHeight()
  417. {
  418. return $this->height;
  419. }
  420. /**
  421. * Get the [bitrate] column value.
  422. *
  423. * @return int
  424. */
  425. public function getBitrate()
  426. {
  427. return $this->bitrate;
  428. }
  429. /**
  430. * Get the [frame_rate] column value.
  431. *
  432. * @return double
  433. */
  434. public function getFrameRate()
  435. {
  436. return $this->frame_rate;
  437. }
  438. /**
  439. * Get the [size] column value.
  440. *
  441. * @return int
  442. */
  443. public function getSize()
  444. {
  445. return $this->size;
  446. }
  447. /**
  448. * Get the [is_original] column value.
  449. *
  450. * @return boolean
  451. */
  452. public function getIsOriginal()
  453. {
  454. return $this->is_original;
  455. }
  456. /**
  457. * Get the [file_ext] column value.
  458. *
  459. * @return string
  460. */
  461. public function getFileExt()
  462. {
  463. return $this->file_ext;
  464. }
  465. /**
  466. * Get the [container_format] column value.
  467. *
  468. * @return string
  469. */
  470. public function getContainerFormat()
  471. {
  472. return $this->container_format;
  473. }
  474. /**
  475. * Get the [video_codec_id] column value.
  476. *
  477. * @return string
  478. */
  479. public function getVideoCodecId()
  480. {
  481. return $this->video_codec_id;
  482. }
  483. /**
  484. * Get the [type] column value.
  485. *
  486. * @return int
  487. */
  488. public function getType()
  489. {
  490. return $this->type;
  491. }
  492. /**
  493. * Get the [custom_data] column value.
  494. *
  495. * @return string
  496. */
  497. public function getCustomData()
  498. {
  499. return $this->custom_data;
  500. }
  501. /**
  502. * Set the value of [id] column.
  503. *
  504. * @param string $v new value
  505. * @return asset The current object (for fluent API support)
  506. */
  507. public function setId($v)
  508. {
  509. if(!isset($this->oldColumnsValues[assetPeer::ID]))
  510. $this->oldColumnsValues[assetPeer::ID] = $this->id;
  511. if ($v !== null) {
  512. $v = (string) $v;
  513. }
  514. if ($this->id !== $v) {
  515. $this->id = $v;
  516. $this->modifiedColumns[] = assetPeer::ID;
  517. }
  518. return $this;
  519. } // setId()
  520. /**
  521. * Set the value of [int_id] column.
  522. *
  523. * @param int $v new value
  524. * @return asset The current object (for fluent API support)
  525. */
  526. public function setIntId($v)
  527. {
  528. if(!isset($this->oldColumnsValues[assetPeer::INT_ID]))
  529. $this->oldColumnsValues[assetPeer::INT_ID] = $this->int_id;
  530. if ($v !== null) {
  531. $v = (int) $v;
  532. }
  533. if ($this->int_id !== $v) {
  534. $this->int_id = $v;
  535. $this->modifiedColumns[] = assetPeer::INT_ID;
  536. }
  537. return $this;
  538. } // setIntId()
  539. /**
  540. * Set the value of [partner_id] column.
  541. *
  542. * @param int $v new value
  543. * @return asset The current object (for fluent API support)
  544. */
  545. public function setPartnerId($v)
  546. {
  547. if(!isset($this->oldColumnsValues[assetPeer::PARTNER_ID]))
  548. $this->oldColumnsValues[assetPeer::PARTNER_ID] = $this->partner_id;
  549. if ($v !== null) {
  550. $v = (int) $v;
  551. }
  552. if ($this->partner_id !== $v) {
  553. $this->partner_id = $v;
  554. $this->modifiedColumns[] = assetPeer::PARTNER_ID;
  555. }
  556. return $this;
  557. } // setPartnerId()
  558. /**
  559. * Set the value of [tags] column.
  560. *
  561. * @param string $v new value
  562. * @return asset The current object (for fluent API support)
  563. */
  564. public function setTags($v)
  565. {
  566. if(!isset($this->oldColumnsValues[assetPeer::TAGS]))
  567. $this->oldColumnsValues[assetPeer::TAGS] = $this->tags;
  568. if ($v !== null) {
  569. $v = (string) $v;
  570. }
  571. if ($this->tags !== $v) {
  572. $this->tags = $v;
  573. $this->modifiedColumns[] = assetPeer::TAGS;
  574. }
  575. return $this;
  576. } // setTags()
  577. /**
  578. * Sets the value of [created_at] column to a normalized version of the date/time value specified.
  579. *
  580. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  581. * be treated as NULL for temporal objects.
  582. * @return asset The current object (for fluent API support)
  583. */
  584. public function setCreatedAt($v)
  585. {
  586. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  587. // -- which is unexpected, to say the least.
  588. if ($v === null || $v === '') {
  589. $dt = null;
  590. } elseif ($v instanceof DateTime) {
  591. $dt = $v;
  592. } else {
  593. // some string/numeric value passed; we normalize that so that we can
  594. // validate it.
  595. try {
  596. if (is_numeric($v)) { // if it's a unix timestamp
  597. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  598. // We have to explicitly specify and then change the time zone because of a
  599. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  600. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  601. } else {
  602. $dt = new DateTime($v);
  603. }
  604. } catch (Exception $x) {
  605. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  606. }
  607. }
  608. if ( $this->created_at !== null || $dt !== null ) {
  609. // (nested ifs are a little easier to read in this case)
  610. $currNorm = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  611. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  612. if ( ($currNorm !== $newNorm) // normalized values don't match
  613. )
  614. {
  615. $this->created_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  616. $this->modifiedColumns[] = assetPeer::CREATED_AT;
  617. }
  618. } // if either are not null
  619. return $this;
  620. } // setCreatedAt()
  621. /**
  622. * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
  623. *
  624. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  625. * be treated as NULL for temporal objects.
  626. * @return asset The current object (for fluent API support)
  627. */
  628. public function setUpdatedAt($v)
  629. {
  630. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  631. // -- which is unexpected, to say the least.
  632. if ($v === null || $v === '') {
  633. $dt = null;
  634. } elseif ($v instanceof DateTime) {
  635. $dt = $v;
  636. } else {
  637. // some string/numeric value passed; we normalize that so that we can
  638. // validate it.
  639. try {
  640. if (is_numeric($v)) { // if it's a unix timestamp
  641. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  642. // We have to explicitly specify and then change the time zone because of a
  643. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  644. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  645. } else {
  646. $dt = new DateTime($v);
  647. }
  648. } catch (Exception $x) {
  649. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  650. }
  651. }
  652. if ( $this->updated_at !== null || $dt !== null ) {
  653. // (nested ifs are a little easier to read in this case)
  654. $currNorm = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  655. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  656. if ( ($currNorm !== $newNorm) // normalized values don't match
  657. )
  658. {
  659. $this->updated_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  660. $this->modifiedColumns[] = assetPeer::UPDATED_AT;
  661. }
  662. } // if either are not null
  663. return $this;
  664. } // setUpdatedAt()
  665. /**
  666. * Sets the value of [deleted_at] column to a normalized version of the date/time value specified.
  667. *
  668. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  669. * be treated as NULL for temporal objects.
  670. * @return asset The current object (for fluent API support)
  671. */
  672. public function setDeletedAt($v)
  673. {
  674. if(!isset($this->oldColumnsValues[assetPeer::DELETED_AT]))
  675. $this->oldColumnsValues[assetPeer::DELETED_AT] = $this->deleted_at;
  676. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  677. // -- which is unexpected, to say the least.
  678. if ($v === null || $v === '') {
  679. $dt = null;
  680. } elseif ($v instanceof DateTime) {
  681. $dt = $v;
  682. } else {
  683. // some string/numeric value passed; we normalize that so that we can
  684. // validate it.
  685. try {
  686. if (is_numeric($v)) { // if it's a unix timestamp
  687. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  688. // We have to explicitly specify and then change the time zone because of a
  689. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  690. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  691. } else {
  692. $dt = new DateTime($v);
  693. }
  694. } catch (Exception $x) {
  695. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  696. }
  697. }
  698. if ( $this->deleted_at !== null || $dt !== null ) {
  699. // (nested ifs are a little easier to read in this case)
  700. $currNorm = ($this->deleted_at !== null && $tmpDt = new DateTime($this->deleted_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  701. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  702. if ( ($currNorm !== $newNorm) // normalized values don't match
  703. )
  704. {
  705. $this->deleted_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  706. $this->modifiedColumns[] = assetPeer::DELETED_AT;
  707. }
  708. } // if either are not null
  709. return $this;
  710. } // setDeletedAt()
  711. /**
  712. * Set the value of [entry_id] column.
  713. *
  714. * @param string $v new value
  715. * @return asset The current object (for fluent API support)
  716. */
  717. public function setEntryId($v)
  718. {
  719. if(!isset($this->oldColumnsValues[assetPeer::ENTRY_ID]))
  720. $this->oldColumnsValues[assetPeer::ENTRY_ID] = $this->entry_id;
  721. if ($v !== null) {
  722. $v = (string) $v;
  723. }
  724. if ($this->entry_id !== $v) {
  725. $this->entry_id = $v;
  726. $this->modifiedColumns[] = assetPeer::ENTRY_ID;
  727. }
  728. if ($this->aentry !== null && $this->aentry->getId() !== $v) {
  729. $this->aentry = null;
  730. }
  731. return $this;
  732. } // setEntryId()
  733. /**
  734. * Set the value of [flavor_params_id] column.
  735. *
  736. * @param int $v new value
  737. * @return asset The current object (for fluent API support)
  738. */
  739. public function setFlavorParamsId($v)
  740. {
  741. if(!isset($this->oldColumnsValues[assetPeer::FLAVOR_PARAMS_ID]))
  742. $this->oldColumnsValues[assetPeer::FLAVOR_PARAMS_ID] = $this->flavor_params_id;
  743. if ($v !== null) {
  744. $v = (int) $v;
  745. }
  746. if ($this->flavor_params_id !== $v) {
  747. $this->flavor_params_id = $v;
  748. $this->modifiedColumns[] = assetPeer::FLAVOR_PARAMS_ID;
  749. }
  750. if ($this->aassetParams !== null && $this->aassetParams->getId() !== $v) {
  751. $this->aassetParams = null;
  752. }
  753. return $this;
  754. } // setFlavorParamsId()
  755. /**
  756. * Set the value of [status] column.
  757. *
  758. * @param int $v new value
  759. * @return asset The current object (for fluent API support)
  760. */
  761. public function setStatus($v)
  762. {
  763. if(!isset($this->oldColumnsValues[assetPeer::STATUS]))
  764. $this->oldColumnsValues[assetPeer::STATUS] = $this->status;
  765. if ($v !== null) {
  766. $v = (int) $v;
  767. }
  768. if ($this->status !== $v) {
  769. $this->status = $v;
  770. $this->modifiedColumns[] = assetPeer::STATUS;
  771. }
  772. return $this;
  773. } // setStatus()
  774. /**
  775. * Set the value of [version] column.
  776. *
  777. * @param string $v new value
  778. * @return asset The current object (for fluent API support)
  779. */
  780. public function setVersion($v)
  781. {
  782. if(!isset($this->oldColumnsValues[assetPeer::VERSION]))
  783. $this->oldColumnsValues[assetPeer::VERSION] = $this->version;
  784. if ($v !== null) {
  785. $v = (string) $v;
  786. }
  787. if ($this->version !== $v) {
  788. $this->version = $v;
  789. $this->modifiedColumns[] = assetPeer::VERSION;
  790. }
  791. return $this;
  792. } // setVersion()
  793. /**
  794. * Set the value of [description] column.
  795. *
  796. * @param string $v new value
  797. * @return asset The current object (for fluent API support)
  798. */
  799. public function setDescription($v)
  800. {
  801. if(!isset($this->oldColumnsValues[assetPeer::DESCRIPTION]))
  802. $this->oldColumnsValues[assetPeer::DESCRIPTION] = $this->description;
  803. if ($v !== null) {
  804. $v = (string) $v;
  805. }
  806. if ($this->description !== $v) {
  807. $this->description = $v;
  808. $this->modifiedColumns[] = assetPeer::DESCRIPTION;
  809. }
  810. return $this;
  811. } // setDescription()
  812. /**
  813. * Set the value of [width] column.
  814. *
  815. * @param int $v new value
  816. * @return asset The current object (for fluent API support)
  817. */
  818. public function setWidth($v)
  819. {
  820. if(!isset($this->oldColumnsValues[assetPeer::WIDTH]))
  821. $this->oldColumnsValues[assetPeer::WIDTH] = $this->width;
  822. if ($v !== null) {
  823. $v = (int) $v;
  824. }
  825. if ($this->width !== $v || $this->isNew()) {
  826. $this->width = $v;
  827. $this->modifiedColumns[] = assetPeer::WIDTH;
  828. }
  829. return $this;
  830. } // setWidth()
  831. /**
  832. * Set the value of [height] column.
  833. *
  834. * @param int $v new value
  835. * @return asset The current object (for fluent API support)
  836. */
  837. public function setHeight($v)
  838. {
  839. if(!isset($this->oldColumnsValues[assetPeer::HEIGHT]))
  840. $this->oldColumnsValues[assetPeer::HEIGHT] = $this->height;
  841. if ($v !== null) {
  842. $v = (int) $v;
  843. }
  844. if ($this->height !== $v || $this->isNew()) {
  845. $this->height = $v;
  846. $this->modifiedColumns[] = assetPeer::HEIGHT;
  847. }
  848. return $this;
  849. } // setHeight()
  850. /**
  851. * Set the value of [bitrate] column.
  852. *
  853. * @param int $v new value
  854. * @return asset The current object (for fluent API support)
  855. */
  856. public function setBitrate($v)
  857. {
  858. if(!isset($this->oldColumnsValues[assetPeer::BITRATE]))
  859. $this->oldColumnsValues[assetPeer::BITRATE] = $this->bitrate;
  860. if ($v !== null) {
  861. $v = (int) $v;
  862. }
  863. if ($this->bitrate !== $v || $this->isNew()) {
  864. $this->bitrate = $v;
  865. $this->modifiedColumns[] = assetPeer::BITRATE;
  866. }
  867. return $this;
  868. } // setBitrate()
  869. /**
  870. * Set the value of [frame_rate] column.
  871. *
  872. * @param double $v new value
  873. * @return asset The current object (for fluent API support)
  874. */
  875. public function setFrameRate($v)
  876. {
  877. if(!isset($this->oldColumnsValues[assetPeer::FRAME_RATE]))
  878. $this->oldColumnsValues[assetPeer::FRAME_RATE] = $this->frame_rate;
  879. if ($v !== null) {
  880. $v = (double) $v;
  881. }
  882. if ($this->frame_rate !== $v || $this->isNew()) {
  883. $this->frame_rate = $v;
  884. $this->modifiedColumns[] = assetPeer::FRAME_RATE;
  885. }
  886. return $this;
  887. } // setFrameRate()
  888. /**
  889. * Set the value of [size] column.
  890. *
  891. * @param int $v new value
  892. * @return asset The current object (for fluent API support)
  893. */
  894. public function setSize($v)
  895. {
  896. if(!isset($this->oldColumnsValues[assetPeer::SIZE]))
  897. $this->oldColumnsValues[assetPeer::SIZE] = $this->size;
  898. if ($v !== null) {
  899. $v = (int) $v;
  900. }
  901. if ($this->size !== $v || $this->isNew()) {
  902. $this->size = $v;
  903. $this->modifiedColumns[] = assetPeer::SIZE;
  904. }
  905. return $this;
  906. } // setSize()
  907. /**
  908. * Set the value of [is_original] column.
  909. *
  910. * @param boolean $v new value
  911. * @return asset The current object (for fluent API support)
  912. */
  913. public function setIsOriginal($v)
  914. {
  915. if(!isset($this->oldColumnsValues[assetPeer::IS_ORIGINAL]))
  916. $this->oldColumnsValues[assetPeer::IS_ORIGINAL] = $this->is_original;
  917. if ($v !== null) {
  918. $v = (boolean) $v;
  919. }
  920. if ($this->is_original !== $v || $this->isNew()) {
  921. $this->is_original = $v;
  922. $this->modifiedColumns[] = assetPeer::IS_ORIGINAL;
  923. }
  924. return $this;
  925. } // setIsOriginal()
  926. /**
  927. * Set the value of [file_ext] column.
  928. *
  929. * @param string $v new value
  930. * @return asset The current object (for fluent API support)
  931. */
  932. public function setFileExt($v)
  933. {
  934. if(!isset($this->oldColumnsValues[assetPeer::FILE_EXT]))
  935. $this->oldColumnsValues[assetPeer::FILE_EXT] = $this->file_ext;
  936. if ($v !== null) {
  937. $v = (string) $v;
  938. }
  939. if ($this->file_ext !== $v) {
  940. $this->file_ext = $v;
  941. $this->modifiedColumns[] = assetPeer::FILE_EXT;
  942. }
  943. return $this;
  944. } // setFileExt()
  945. /**
  946. * Set the value of [container_format] column.
  947. *
  948. * @param string $v new value
  949. * @return asset The current object (for fluent API support)
  950. */
  951. public function setContainerFormat($v)
  952. {
  953. if(!isset($this->oldColumnsValues[assetPeer::CONTAINER_FORMAT]))
  954. $this->oldColumnsValues[assetPeer::CONTAINER_FORMAT] = $this->container_format;
  955. if ($v !== null) {
  956. $v = (string) $v;
  957. }
  958. if ($this->container_format !== $v) {
  959. $this->container_format = $v;
  960. $this->modifiedColumns[] = assetPeer::CONTAINER_FORMAT;
  961. }
  962. return $this;
  963. } // setContainerFormat()
  964. /**
  965. * Set the value of [video_codec_id] column.
  966. *
  967. * @param string $v new value
  968. * @return asset The current object (for fluent API support)
  969. */
  970. public function setVideoCodecId($v)
  971. {
  972. if(!isset($this->oldColumnsValues[assetPeer::VIDEO_CODEC_ID]))
  973. $this->oldColumnsValues[assetPeer::VIDEO_CODEC_ID] = $this->video_codec_id;
  974. if ($v !== null) {
  975. $v = (string) $v;
  976. }
  977. if ($this->video_codec_id !== $v) {
  978. $this->video_codec_id = $v;
  979. $this->modifiedColumns[] = assetPeer::VIDEO_CODEC_ID;
  980. }
  981. return $this;
  982. } // setVideoCodecId()
  983. /**
  984. * Set the value of [type] column.
  985. *
  986. * @param int $v new value
  987. * @return asset The current object (for fluent API support)
  988. */
  989. public function setType($v)
  990. {
  991. if(!isset($this->oldColumnsValues[assetPeer::TYPE]))
  992. $this->oldColumnsValues[assetPeer::TYPE] = $this->type;
  993. if ($v !== null) {
  994. $v = (int) $v;
  995. }
  996. if ($this->type !== $v || $this->isNew()) {
  997. $this->type = $v;
  998. $this->modifiedColumns[] = assetPeer::TYPE;
  999. }
  1000. return $this;
  1001. } // setType()
  1002. /**
  1003. * Set the value of [custom_data] column.
  1004. *
  1005. * @param string $v new value
  1006. * @return asset The current object (for fluent API support)
  1007. */
  1008. public function setCustomData($v)
  1009. {
  1010. if ($v !== null) {
  1011. $v = (string) $v;
  1012. }
  1013. if ($this->custom_data !== $v) {
  1014. $this->custom_data = $v;
  1015. $this->modifiedColumns[] = assetPeer::CUSTOM_DATA;
  1016. }
  1017. return $this;
  1018. } // setCustomData()
  1019. /**
  1020. * Indicates whether the columns in this object are only set to default values.
  1021. *
  1022. * This method can be used in conjunction with isModified() to indicate whether an object is both
  1023. * modified _and_ has some values set which are non-default.
  1024. *
  1025. * @return boolean Whether the columns in this object are only been set with default values.
  1026. */
  1027. public function hasOnlyDefaultValues()
  1028. {
  1029. if ($this->width !== 0) {
  1030. return false;
  1031. }
  1032. if ($this->height !== 0) {
  1033. return false;
  1034. }
  1035. if ($this->bitrate !== 0) {
  1036. return false;
  1037. }
  1038. if ($this->frame_rate !== 0) {
  1039. return false;
  1040. }
  1041. if ($this->size !== 0) {
  1042. return false;
  1043. }
  1044. if ($this->is_original !== false) {
  1045. return false;
  1046. }
  1047. if ($this->type !== 0) {
  1048. return false;
  1049. }
  1050. // otherwise, everything was equal, so return TRUE
  1051. return true;
  1052. } // hasOnlyDefaultValues()
  1053. /**
  1054. * Hydrates (populates) the object variables with values from the database resultset.
  1055. *
  1056. * An offset (0-based "start column") is specified so that objects can be hydrated
  1057. * with a subset of the columns in the resultset rows. This is needed, for example,
  1058. * for results of JOIN queries where the resultset row includes columns from two or
  1059. * more tables.
  1060. *
  1061. * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  1062. * @param int $startcol 0-based offset column which indicates which restultset column to start with.
  1063. * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
  1064. * @return int next starting column
  1065. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  1066. */
  1067. public function hydrate($row, $startcol = 0, $rehydrate = false)
  1068. {
  1069. try {
  1070. $this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
  1071. $this->int_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
  1072. $this->partner_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
  1073. $this->tags = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
  1074. $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
  1075. $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
  1076. $this->deleted_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
  1077. $this->entry_id = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
  1078. $this->flavor_params_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
  1079. $this->status = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
  1080. $this->version = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
  1081. $this->description = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
  1082. $this->width = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null;
  1083. $this->height = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null;
  1084. $this->bitrate = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
  1085. $this->frame_rate = ($row[$startcol + 15] !== null) ? (double) $row[$startcol + 15] : null;
  1086. $this->size = ($row[$startcol + 16] !== null) ? (int) $row[$startcol + 16] : null;
  1087. $this->is_original = ($row[$startcol + 17] !== null) ? (boolean) $row[$startcol + 17] : null;
  1088. $this->file_ext = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null;
  1089. $this->container_format = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null;
  1090. $this->video_codec_id = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null;
  1091. $this->type = ($row[$startcol + 21] !== null) ? (int) $row[$startcol + 21] : null;
  1092. $this->custom_data = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null;
  1093. $this->resetModified();
  1094. $this->setNew(false);
  1095. if ($rehydrate) {
  1096. $this->ensureConsistency();
  1097. }
  1098. // FIXME - using NUM_COLUMNS may be clearer.
  1099. return $startcol + 23; // 23 = assetPeer::NUM_COLUMNS - assetPeer::NUM_LAZY_LOAD_COLUMNS).
  1100. } catch (Exception $e) {
  1101. throw new PropelException("Error populating asset object", $e);
  1102. }
  1103. }
  1104. /**
  1105. * Checks and repairs the internal consistency of the object.
  1106. *
  1107. * This method is executed after an already-instantiated object is re-hydrated
  1108. * from the database. It exists to check any foreign keys to make sure that
  1109. * the objects related to the current object are correct based on foreign key.
  1110. *
  1111. * You can override this method in the stub class, but you should always invoke
  1112. * the base method from the overridden method (i.e. parent::ensureConsistency()),
  1113. * in case your model changes.
  1114. *
  1115. * @throws PropelException
  1116. */
  1117. public function ensureConsistency()
  1118. {
  1119. if ($this->aentry !== null && $this->entry_id !== $this->aentry->getId()) {
  1120. $this->aentry = null;
  1121. }
  1122. if ($this->aassetParams !== null && $this->flavor_params_id !== $this->aassetParams->getId()) {
  1123. $this->aassetParams = null;
  1124. }
  1125. } // ensureConsistency
  1126. /**
  1127. * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  1128. *
  1129. * This will only work if the object has been saved and has a valid primary key set.
  1130. *
  1131. * @param boolean $deep (optional) Whether to also de-associated any related objects.
  1132. * @param PropelPDO $con (optional) The PropelPDO connection to use.
  1133. * @return void
  1134. * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  1135. */
  1136. public function reload($deep = false, PropelPDO $con = null)
  1137. {
  1138. if ($this->isDeleted()) {
  1139. throw new PropelException("Cannot reload a deleted object.");
  1140. }
  1141. if ($this->isNew()) {
  1142. throw new PropelException("Cannot reload an unsaved object.");
  1143. }
  1144. if ($con === null) {
  1145. $con = Propel::getConnection(assetPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  1146. }
  1147. // We don't need to alter the object instance pool; we're just modifying this instance
  1148. // already in the pool.
  1149. assetPeer::setUseCriteriaFilter(false);
  1150. $stmt = assetPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  1151. assetPeer::setUseCriteriaFilter(true);
  1152. $row = $stmt->fetch(PDO::FETCH_NUM);
  1153. $stmt->closeCursor();
  1154. if (!$row) {
  1155. throw new PropelException('Cannot find matching row in the database to reload object values.');
  1156. }
  1157. $this->hydrate($row, 0, true); // rehydrate
  1158. if ($deep) { // also de-associate any related objects?
  1159. $this->aentry = null;
  1160. $this->aassetParams = null;
  1161. $this->collmediaInfos = null;
  1162. $this->lastmediaInfoCriteria = null;
  1163. $this->collassetParamsOutputs = null;
  1164. $this->lastassetParamsOutputCriteria = null;
  1165. } // if (deep)
  1166. }
  1167. /**
  1168. * Removes this object from datastore and sets delete attribute.
  1169. *
  1170. * @param PropelPDO $con
  1171. * @return void
  1172. * @throws PropelException
  1173. * @see BaseObject::setDeleted()
  1174. * @see BaseObject::isDeleted()
  1175. */
  1176. public function delete(PropelPDO $con = null)
  1177. {
  1178. if ($this->isDeleted()) {
  1179. throw new PropelException("This object has already been deleted.");
  1180. }
  1181. if ($con === null) {
  1182. $con = Propel::getConnection(assetPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1183. }
  1184. $con->beginTransaction();
  1185. try {
  1186. $ret = $this->preDelete($con);
  1187. if ($ret) {
  1188. assetPeer::doDelete($this, $con);
  1189. $this->postDelete($con);
  1190. $this->setDeleted(true);
  1191. $con->commit();
  1192. } else {
  1193. $con->commit();
  1194. }
  1195. } catch (PropelException $e) {
  1196. $con->rollBack();
  1197. throw $e;
  1198. }
  1199. }
  1200. /**
  1201. * Persists this object to the database.
  1202. *
  1203. * If the object is new, it inserts it; otherwise an update is performed.
  1204. * All modified related objects will also be persisted in the doSave()
  1205. * method. This method wraps all precipitate database operations in a
  1206. * single transaction.
  1207. *
  1208. * @param PropelPDO $con
  1209. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  1210. * @throws PropelException
  1211. * @see doSave()
  1212. */
  1213. public function save(PropelPDO $con = null)
  1214. {
  1215. if ($this->isDeleted()) {
  1216. throw new PropelException("You cannot save an object that has been deleted.");
  1217. }
  1218. if ($con === null) {
  1219. $con = Propel::getConnection(assetPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1220. }
  1221. $con->beginTransaction();
  1222. $isInsert = $this->isNew();
  1223. try {
  1224. $ret = $this->preSave($con);
  1225. if ($isInsert) {
  1226. $ret = $ret && $this->preInsert($con);
  1227. } else {
  1228. $ret = $ret && $this->preUpdate($con);
  1229. }
  1230. if ($ret) {
  1231. $affectedRows = $this->doSave($con);
  1232. if ($isInsert) {
  1233. $this->postInsert($con);
  1234. } else {
  1235. $this->postUpdate($con);
  1236. }
  1237. $this->postSave($con);
  1238. assetPeer::addInstanceToPool($this);
  1239. } else {
  1240. $affectedRows = 0;
  1241. }
  1242. $con->commit();
  1243. return $affectedRows;
  1244. } catch (PropelException $e) {
  1245. $con->rollBack();
  1246. throw $e;
  1247. }
  1248. }
  1249. /**
  1250. * Performs the work of inserting or updating the row in the database.
  1251. *
  1252. * If the object is new, it inserts it; otherwise an update is performed.
  1253. * All related objects are also updated in this method.
  1254. *
  1255. * @param PropelPDO $con
  1256. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  1257. * @throws PropelException
  1258. * @see save()
  1259. */
  1260. protected function doSave(PropelPDO $con)
  1261. {
  1262. $affectedRows = 0; // initialize var to track total num of affected rows
  1263. if (!$this->alreadyInSave) {
  1264. $this->alreadyInSave = true;
  1265. // We call the save method on the following object(s) if they
  1266. // were passed to this object by their coresponding set
  1267. // method. This object relates to these object(s) by a
  1268. // foreign key reference.
  1269. if ($this->aentry !== null) {
  1270. if ($this->aentry->isModified() || $this->aentry->isNew()) {
  1271. $affectedRows += $this->aentry->save($con);
  1272. }
  1273. $this->setentry($this->aentry);
  1274. }
  1275. if ($this->aassetParams !== null) {
  1276. if ($this->aassetParams->isModified() || $this->aassetParams->isNew()) {
  1277. $affectedRows += $this->aassetParams->save($con);
  1278. }
  1279. $this->setassetParams($this->aassetParams);
  1280. }
  1281. if ($this->isNew() ) {
  1282. $this->modifiedColumns[] = assetPeer::INT_ID;
  1283. }
  1284. // If this object has been modified, then save it to the database.
  1285. if ($this->isModified()) {
  1286. if ($this->isNew()) {
  1287. $pk = assetPeer::doInsert($this, $con);
  1288. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  1289. // should always be true here (even though technically
  1290. // BasePeer::doInsert() can insert multiple rows).
  1291. $this->setIntId($pk); //[IMV] update autoincrement primary key
  1292. $this->setNew(false);
  1293. } else {
  1294. $affectedRows += assetPeer::doUpdate($this, $con);
  1295. }
  1296. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  1297. }
  1298. if ($this->collmediaInfos !== null) {
  1299. foreach ($this->collmediaInfos as $referrerFK) {
  1300. if (!$referrerFK->isDeleted()) {
  1301. $affectedRows += $referrerFK->save($con);
  1302. }
  1303. }
  1304. }
  1305. if ($this->collassetParamsOutputs !== null) {
  1306. foreach ($this->collassetParamsOutputs as $referrerFK) {
  1307. if (!$referrerFK->isDeleted()) {
  1308. $affectedRows += $referrerFK->save($con);
  1309. }
  1310. }
  1311. }
  1312. $this->alreadyInSave = false;
  1313. }
  1314. return $affectedRows;
  1315. } // doSave()
  1316. /**
  1317. * Override in order to use the query cache.
  1318. * Cache invalidation keys are used to determine when cached queries are valid.
  1319. * Before returning a query result from the cache, the time of the cached query
  1320. * is compared to the time saved in the invalidation key.
  1321. * A cached query will only be used if it's newer than the matching invalidation key.
  1322. *
  1323. * @return array Array of keys that will should be updated when this object is modified.
  1324. */
  1325. public function getCacheInvalidationKeys()
  1326. {
  1327. return array();
  1328. }
  1329. /**
  1330. * Code to be run before persisting the object
  1331. * @param PropelPDO $con
  1332. * @return bloolean
  1333. */
  1334. public function preSave(PropelPDO $con = null)
  1335. {
  1336. $this->setCustomDataObj();
  1337. return parent::preSave($con);
  1338. }
  1339. /**
  1340. * Code to be run after persisting the object
  1341. * @param PropelPDO $con
  1342. */
  1343. public function postSave(PropelPDO $con = null)
  1344. {
  1345. $this->oldColumnsValues = array();
  1346. $this->oldCustomDataValues = array();
  1347. }
  1348. /**
  1349. * Code to be run before inserting to database
  1350. * @param PropelPDO $con
  1351. * @return boolean
  1352. */
  1353. public function preInsert(PropelPDO $con = null)
  1354. {
  1355. $this->setCreatedAt(time());
  1356. $this->setUpdatedAt(time());
  1357. return true;
  1358. }
  1359. /**
  1360. * Code to be run after inserting to database
  1361. * @param PropelPDO $con
  1362. */
  1363. public function postInsert(PropelPDO $con = null)
  1364. {
  1365. kQueryCache::invalidateQueryCache($this);
  1366. kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
  1367. if($this->copiedFrom)
  1368. kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
  1369. }
  1370. /**
  1371. * Code to be run after updating the object in database
  1372. * @param PropelPDO $con
  1373. */
  1374. public function postUpdate(PropelPDO $con = null)
  1375. {
  1376. if ($this->alreadyInSave)
  1377. {
  1378. return;
  1379. }
  1380. if($this->isModified())
  1381. {
  1382. kQueryCache::invalidateQueryCache($this);
  1383. kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->tempModifiedColumns));
  1384. }
  1385. $this->tempModifiedColumns = array();
  1386. }
  1387. /**
  1388. * Saves the modified columns temporarily while saving
  1389. * @var array
  1390. */
  1391. private $tempModifiedColumns = array();
  1392. /**
  1393. * Returns whether the object has been modified.
  1394. *
  1395. * @return boolean True if the object has been modified.
  1396. */
  1397. public function isModified()
  1398. {
  1399. if(!empty($this->tempModifiedColumns))
  1400. return true;
  1401. return !empty($this->modifiedColumns);
  1402. }
  1403. /**
  1404. * Has specified column been modified?
  1405. *
  1406. * @param string $col
  1407. * @return boolean True if $col has been modified.
  1408. */
  1409. public function isColumnModified($col)
  1410. {
  1411. if(in_array($col, $this->tempModifiedColumns))
  1412. return true;
  1413. return in_array($col, $this->modifiedColumns);
  1414. }
  1415. /**
  1416. * Code to be run before updating the object in database
  1417. * @param PropelPDO $con
  1418. * @return boolean
  1419. */
  1420. public function preUpdate(PropelPDO $con = null)
  1421. {
  1422. if ($this->alreadyInSave)
  1423. {
  1424. return true;
  1425. }
  1426. if($this->isModified())
  1427. $this->setUpdatedAt(time());
  1428. $this->tempModifiedColumns = $this->modifiedColumns;
  1429. return true;
  1430. }
  1431. /**
  1432. * Array of ValidationFailed objects.
  1433. * @var array ValidationFailed[]
  1434. */
  1435. protected $validationFailures = array();
  1436. /**
  1437. * Gets any ValidationFailed objects that resulted from last call to validate().
  1438. *
  1439. *
  1440. * @return array ValidationFailed[]
  1441. * @see validate()
  1442. */
  1443. public function getValidationFailures()
  1444. {
  1445. return $this->validationFailures;
  1446. }
  1447. /**
  1448. * Validates the objects modified field values and all objects related to this table.
  1449. *
  1450. * If $columns is either a column name or an array of column names
  1451. * only those columns are validated.
  1452. *
  1453. * @param mixed $columns Column name or an array of column names.
  1454. * @return boolean Whether all columns pass validation.
  1455. * @see doValidate()
  1456. * @see getValidationFailures()
  1457. */
  1458. public function validate($columns = null)
  1459. {
  1460. $res = $this->doValidate($columns);
  1461. if ($res === true) {
  1462. $this->validationFailures = array();
  1463. return true;
  1464. } else {
  1465. $this->validationFailures = $res;
  1466. return false;
  1467. }
  1468. }
  1469. /**
  1470. * This function performs the validation work for complex object models.
  1471. *
  1472. * In addition to checking the current object, all related objects will
  1473. * also be validated. If all pass then <code>true</code> is returned; otherwise
  1474. * an aggreagated array of ValidationFailed objects will be returned.
  1475. *
  1476. * @param array $columns Array of column names to validate.
  1477. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  1478. */
  1479. protected function doValidate($columns = null)
  1480. {
  1481. if (!$this->alreadyInValidation) {
  1482. $this->alreadyInValidation = true;
  1483. $retval = null;
  1484. $failureMap = array();
  1485. // We call the validate method on the following object(s) if they
  1486. // were passed to this object by their coresponding set
  1487. // method. This object relates to these object(s) by a
  1488. // foreign key reference.
  1489. if ($this->aentry !== null) {
  1490. if (!$this->aentry->validate($columns)) {
  1491. $failureMap = array_merge($failureMap, $this->aentry->getValidationFailures());
  1492. }
  1493. }
  1494. if ($this->aassetParams !== null) {
  1495. if (!$this->aassetParams->validate($columns)) {
  1496. $failureMap = array_merge($failureMap, $this->aassetParams->getValidationFailures());
  1497. }
  1498. }
  1499. if (($retval = assetPeer::doValidate($this, $columns)) !== true) {
  1500. $failureMap = array_merge($failureMap, $retval);
  1501. }
  1502. if ($this->collmediaInfos !== null) {
  1503. foreach ($this->collmediaInfos as $referrerFK) {
  1504. if (!$referrerFK->validate($columns)) {
  1505. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  1506. }
  1507. }
  1508. }
  1509. if ($this->collassetParamsOutputs !== null) {
  1510. foreach ($this->collassetParamsOutputs as $referrerFK) {
  1511. if (!$referrerFK->validate($columns)) {
  1512. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  1513. }
  1514. }
  1515. }
  1516. $this->alreadyInValidation = false;
  1517. }
  1518. return (!empty($failureMap) ? $failureMap : true);
  1519. }
  1520. /**
  1521. * Retrieves a field from the object by name passed in as a string.
  1522. *
  1523. * @param string $name name
  1524. * @param string $type The type of fieldname the $name is of:
  1525. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1526. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  1527. * @return mixed Value of field.
  1528. */
  1529. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  1530. {
  1531. $pos = assetPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  1532. $field = $this->getByPosition($pos);
  1533. return $field;
  1534. }
  1535. /**
  1536. * Retrieves a field from the object by Position as specified in the xml schema.
  1537. * Zero-based.
  1538. *
  1539. * @param int $pos position in xml schema
  1540. * @return mixed Value of field at $pos
  1541. */
  1542. public function getByPosition($pos)
  1543. {
  1544. switch($pos) {
  1545. case 0:
  1546. return $this->getId();
  1547. break;
  1548. case 1:
  1549. return $this->getIntId();
  1550. break;
  1551. case 2:
  1552. return $this->getPartnerId();
  1553. break;
  1554. case 3:
  1555. return $this->getTags();
  1556. break;
  1557. case 4:
  1558. return $this->getCreatedAt();
  1559. break;
  1560. case 5:
  1561. return $this->getUpdatedAt();
  1562. break;
  1563. case 6:
  1564. return $this->getDeletedAt();
  1565. break;
  1566. case 7:
  1567. return $this->getEntryId();
  1568. break;
  1569. case 8:
  1570. return $this->getFlavorParamsId();
  1571. break;
  1572. case 9:
  1573. return $this->getStatus();
  1574. break;
  1575. case 10:
  1576. return $this->getVersion();
  1577. break;
  1578. case 11:
  1579. return $this->getDescription();
  1580. break;
  1581. case 12:
  1582. return $this->getWidth();
  1583. break;
  1584. case 13:
  1585. return $this->getHeight();
  1586. break;
  1587. case 14:
  1588. return $this->getBitrate();
  1589. break;
  1590. case 15:
  1591. return $this->getFrameRate();
  1592. break;
  1593. case 16:
  1594. return $this->getSize();
  1595. break;
  1596. case 17:
  1597. return $this->getIsOriginal();
  1598. break;
  1599. case 18:
  1600. return $this->getFileExt();
  1601. break;
  1602. case 19:
  1603. return $this->getContainerFormat();
  1604. break;
  1605. case 20:
  1606. return $this->getVideoCodecId();
  1607. break;
  1608. case 21:
  1609. return $this->getType();
  1610. break;
  1611. case 22:
  1612. return $this->getCustomData();
  1613. break;
  1614. default:
  1615. return null;
  1616. break;
  1617. } // switch()
  1618. }
  1619. /**
  1620. * Exports the object as an array.
  1621. *
  1622. * You can specify the key type of the array by passing one of the class
  1623. * type constants.
  1624. *
  1625. * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1626. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
  1627. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  1628. * @return an associative array containing the field names (as keys) and field values
  1629. */
  1630. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
  1631. {
  1632. $keys = assetPeer::getFieldNames($keyType);
  1633. $result = array(
  1634. $keys[0] => $this->getId(),
  1635. $keys[1] => $this->getIntId(),
  1636. $keys[2] => $this->getPartnerId(),
  1637. $keys[3] => $this->getTags(),
  1638. $keys[4] => $this->getCreatedAt(),
  1639. $keys[5] => $this->getUpdatedAt(),
  1640. $keys[6] => $this->getDeletedAt(),
  1641. $keys[7] => $this->getEntryId(),
  1642. $keys[8] => $this->getFlavorParamsId(),
  1643. $keys[9] => $this->getStatus(),
  1644. $keys[10] => $this->getVersion(),
  1645. $keys[11] => $this->getDescription(),
  1646. $keys[12] => $this->getWidth(),
  1647. $keys[13] => $this->getHeight(),
  1648. $keys[14] => $this->getBitrate(),
  1649. $keys[15] => $this->getFrameRate(),
  1650. $keys[16] => $this->getSize(),
  1651. $keys[17] => $this->getIsOriginal(),
  1652. $keys[18] => $this->getFileExt(),
  1653. $keys[19] => $this->getContainerFormat(),
  1654. $keys[20] => $this->getVideoCodecId(),
  1655. $keys[21] => $this->getType(),
  1656. $keys[22] => $this->getCustomData(),
  1657. );
  1658. return $result;
  1659. }
  1660. /**
  1661. * Sets a field from the object by name passed in as a string.
  1662. *
  1663. * @param string $name peer name
  1664. * @param mixed $value field value
  1665. * @param string $type The type of fieldname the $name is of:
  1666. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1667. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  1668. * @return void
  1669. */
  1670. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  1671. {
  1672. $pos = assetPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  1673. return $this->setByPosition($pos, $value);
  1674. }
  1675. /**
  1676. * Sets a field from the object by Position as specified in the xml schema.
  1677. * Zero-based.
  1678. *
  1679. * @param int $pos position in xml schema
  1680. * @param mixed $value field value
  1681. * @return void
  1682. */
  1683. public function setByPosition($pos, $value)
  1684. {
  1685. switch($pos) {
  1686. case 0:
  1687. $this->setId($value);
  1688. break;
  1689. case 1:
  1690. $this->setIntId($value);
  1691. break;
  1692. case 2:
  1693. $this->setPartnerId($value);
  1694. break;
  1695. case 3:
  1696. $this->setTags($value);
  1697. break;
  1698. case 4:
  1699. $this->setCreatedAt($value);
  1700. break;
  1701. case 5:
  1702. $this->setUpdatedAt($value);
  1703. break;
  1704. case 6:
  1705. $this->setDeletedAt($value);
  1706. break;
  1707. case 7:
  1708. $this->setEntryId($value);
  1709. break;
  1710. case 8:
  1711. $this->setFlavorParamsId($value);
  1712. break;
  1713. case 9:
  1714. $this->setStatus($value);
  1715. break;
  1716. case 10:
  1717. $this->setVersion($value);
  1718. break;
  1719. case 11:
  1720. $this->setDescription($value);
  1721. break;
  1722. case 12:
  1723. $this->setWidth($value);
  1724. break;
  1725. case 13:
  1726. $this->setHeight($value);
  1727. break;
  1728. case 14:
  1729. $this->setBitrate($value);
  1730. break;
  1731. case 15:
  1732. $this->setFrameRate($value);
  1733. break;
  1734. case 16:
  1735. $this->setSize($value);
  1736. break;
  1737. case 17:
  1738. $this->setIsOriginal($value);
  1739. break;
  1740. case 18:
  1741. $this->setFileExt($value);
  1742. break;
  1743. case 19:
  1744. $this->setContainerFormat($value);
  1745. break;
  1746. case 20:
  1747. $this->setVideoCodecId($value);
  1748. break;
  1749. case 21:
  1750. $this->setType($value);
  1751. break;
  1752. case 22:
  1753. $this->setCustomData($value);
  1754. break;
  1755. } // switch()
  1756. }
  1757. /**
  1758. * Populates the object using an array.
  1759. *
  1760. * This is particularly useful when populating an object from one of the
  1761. * request arrays (e.g. $_POST). This method goes through the column
  1762. * names, checking to see whether a matching key exists in populated
  1763. * array. If so the setByName() method is called for that column.
  1764. *
  1765. * You can specify the key type of the array by additionally passing one
  1766. * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1767. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1768. * The default key type is the column's phpname (e.g. 'AuthorId')
  1769. *
  1770. * @param array $arr An array to populate the object from.
  1771. * @param string $keyType The type of keys the array uses.
  1772. * @return void
  1773. */
  1774. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  1775. {
  1776. $keys = assetPeer::getFieldNames($keyType);
  1777. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  1778. if (array_key_exists($keys[1], $arr)) $this->setIntId($arr[$keys[1]]);
  1779. if (array_key_exists($keys[2], $arr)) $this->setPartnerId($arr[$keys[2]]);
  1780. if (array_key_exists($keys[3], $arr)) $this->setTags($arr[$keys[3]]);
  1781. if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
  1782. if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
  1783. if (array_key_exists($keys[6], $arr)) $this->setDeletedAt($arr[$keys[6]]);
  1784. if (array_key_exists($keys[7], $arr)) $this->setEntryId($arr[$keys[7]]);
  1785. if (array_key_exists($keys[8], $arr)) $this->setFlavorParamsId($arr[$keys[8]]);
  1786. if (array_key_exists($keys[9], $arr)) $this->setStatus($arr[$keys[9]]);
  1787. if (array_key_exists($keys[10], $arr)) $this->setVersion($arr[$keys[10]]);
  1788. if (array_key_exists($keys[11], $arr)) $this->setDescription($arr[$keys[11]]);
  1789. if (array_key_exists($keys[12], $arr)) $this->setWidth($arr[$keys[12]]);
  1790. if (array_key_exists($keys[13], $arr)) $this->setHeight($arr[$keys[13]]);
  1791. if (array_key_exists($keys[14], $arr)) $this->setBitrate($arr[$keys[14]]);
  1792. if (array_key_exists($keys[15], $arr)) $this->setFrameRate($arr[$keys[15]]);
  1793. if (array_key_exists($keys[16], $arr)) $this->setSize($arr[$keys[16]]);
  1794. if (array_key_exists($keys[17], $arr)) $this->setIsOriginal($arr[$keys[17]]);
  1795. if (array_key_exists($keys[18], $arr)) $this->setFileExt($arr[$keys[18]]);
  1796. if (array_key_exists($keys[19], $arr)) $this->setContainerFormat($arr[$keys[19]]);
  1797. if (array_key_exists($keys[20], $arr)) $this->setVideoCodecId($arr[$keys[20]]);
  1798. if (array_key_exists($keys[21], $arr)) $this->setType($arr[$keys[21]]);
  1799. if (array_key_exists($keys[22], $arr)) $this->setCustomData($arr[$keys[22]]);
  1800. }
  1801. /**
  1802. * Build a Criteria object containing the values of all modified columns in this object.
  1803. *
  1804. * @return Criteria The Criteria object containing all modified values.
  1805. */
  1806. public function buildCriteria()
  1807. {
  1808. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  1809. if ($this->isColumnModified(assetPeer::ID)) $criteria->add(assetPeer::ID, $this->id);
  1810. if ($this->isColumnModified(assetPeer::INT_ID)) $criteria->add(assetPeer::INT_ID, $this->int_id);
  1811. if ($this->isColumnModified(assetPeer::PARTNER_ID)) $criteria->add(assetPeer::PARTNER_ID, $this->partner_id);
  1812. if ($this->isColumnModified(assetPeer::TAGS)) $criteria->add(assetPeer::TAGS, $this->tags);
  1813. if ($this->isColumnModified(assetPeer::CREATED_AT)) $criteria->add(assetPeer::CREATED_AT, $this->created_at);
  1814. if ($this->isColumnModified(assetPeer::UPDATED_AT)) $criteria->add(assetPeer::UPDATED_AT, $this->updated_at);
  1815. if ($this->isColumnModified(assetPeer::DELETED_AT)) $criteria->add(assetPeer::DELETED_AT, $this->deleted_at);
  1816. if ($this->isColumnModified(assetPeer::ENTRY_ID)) $criteria->add(assetPeer::ENTRY_ID, $this->entry_id);
  1817. if ($this->isColumnModified(assetPeer::FLAVOR_PARAMS_ID)) $criteria->add(assetPeer::FLAVOR_PARAMS_ID, $this->flavor_params_id);
  1818. if ($this->isColumnModified(assetPeer::STATUS)) $criteria->add(assetPeer::STATUS, $this->status);
  1819. if ($this->isColumnModified(assetPeer::VERSION)) $criteria->add(assetPeer::VERSION, $this->version);
  1820. if ($this->isColumnModified(assetPeer::DESCRIPTION)) $criteria->add(assetPeer::DESCRIPTION, $this->description);
  1821. if ($this->isColumnModified(assetPeer::WIDTH)) $criteria->add(assetPeer::WIDTH, $this->width);
  1822. if ($this->isColumnModified(assetPeer::HEIGHT)) $criteria->add(assetPeer::HEIGHT, $this->height);
  1823. if ($this->isColumnModified(assetPeer::BITRATE)) $criteria->add(assetPeer::BITRATE, $this->bitrate);
  1824. if ($this->isColumnModified(assetPeer::FRAME_RATE)) $criteria->add(assetPeer::FRAME_RATE, $this->frame_rate);
  1825. if ($this->isColumnModified(assetPeer::SIZE)) $criteria->add(assetPeer::SIZE, $this->size);
  1826. if ($this->isColumnModified(assetPeer::IS_ORIGINAL)) $criteria->add(assetPeer::IS_ORIGINAL, $this->is_original);
  1827. if ($this->isColumnModified(assetPeer::FILE_EXT)) $criteria->add(assetPeer::FILE_EXT, $this->file_ext);
  1828. if ($this->isColumnModified(assetPeer::CONTAINER_FORMAT)) $criteria->add(assetPeer::CONTAINER_FORMAT, $this->container_format);
  1829. if ($this->isColumnModified(assetPeer::VIDEO_CODEC_ID)) $criteria->add(assetPeer::VIDEO_CODEC_ID, $this->video_codec_id);
  1830. if ($this->isColumnModified(assetPeer::TYPE)) $criteria->add(assetPeer::TYPE, $this->type);
  1831. if ($this->isColumnModified(assetPeer::CUSTOM_DATA)) $criteria->add(assetPeer::CUSTOM_DATA, $this->custom_data);
  1832. return $criteria;
  1833. }
  1834. /**
  1835. * Builds a Criteria object containing the primary key for this object.
  1836. *
  1837. * Unlike buildCriteria() this method includes the primary key values regardless
  1838. * of whether or not they have been modified.
  1839. *
  1840. * @return Criteria The Criteria object containing value(s) for primary key(s).
  1841. */
  1842. public function buildPkeyCriteria()
  1843. {
  1844. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  1845. $criteria->add(assetPeer::INT_ID, $this->int_id);
  1846. return $criteria;
  1847. }
  1848. /**
  1849. * Returns the primary key for this object (row).
  1850. * @return int
  1851. */
  1852. public function getPrimaryKey()
  1853. {
  1854. return $this->getIntId();
  1855. }
  1856. /**
  1857. * Generic method to set the primary key (int_id column).
  1858. *
  1859. * @param int $key Primary key.
  1860. * @return void
  1861. */
  1862. public function setPrimaryKey($key)
  1863. {
  1864. $this->setIntId($key);
  1865. }
  1866. /**
  1867. * Sets contents of passed object to values from current object.
  1868. *
  1869. * If desired, this method can also make copies of all associated (fkey referrers)
  1870. * objects.
  1871. *
  1872. * @param object $copyObj An object of asset (or compatible) type.
  1873. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1874. * @throws PropelException
  1875. */
  1876. public function copyInto($copyObj, $deepCopy = false)
  1877. {
  1878. $copyObj->setId($this->id);
  1879. $copyObj->setPartnerId($this->partner_id);
  1880. $copyObj->setTags($this->tags);
  1881. $copyObj->setCreatedAt($this->created_at);
  1882. $copyObj->setUpdatedAt($this->updated_at);
  1883. $copyObj->setDeletedAt($this->deleted_at);
  1884. $copyObj->setEntryId($this->entry_id);
  1885. $copyObj->setFlavorParamsId($this->flavor_params_id);
  1886. $copyObj->setStatus($this->status);
  1887. $copyObj->setVersion($this->version);
  1888. $copyObj->setDescription($this->description);
  1889. $copyObj->setWidth($this->width);
  1890. $copyObj->setHeight($this->height);
  1891. $copyObj->setBitrate($this->bitrate);
  1892. $copyObj->setFrameRate($this->frame_rate);
  1893. $copyObj->setSize($this->size);
  1894. $copyObj->setIsOriginal($this->is_original);
  1895. $copyObj->setFileExt($this->file_ext);
  1896. $copyObj->setContainerFormat($this->container_format);
  1897. $copyObj->setVideoCodecId($this->video_codec_id);
  1898. $copyObj->setType($this->type);
  1899. $copyObj->setCustomData($this->custom_data);
  1900. if ($deepCopy) {
  1901. // important: temporarily setNew(false) because this affects the behavior of
  1902. // the getter/setter methods for fkey referrer objects.
  1903. $copyObj->setNew(false);
  1904. foreach ($this->getmediaInfos() as $relObj) {
  1905. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1906. $copyObj->addmediaInfo($relObj->copy($deepCopy));
  1907. }
  1908. }
  1909. foreach ($this->getassetParamsOutputs() as $relObj) {
  1910. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1911. $copyObj->addassetParamsOutput($relObj->copy($deepCopy));
  1912. }
  1913. }
  1914. } // if ($deepCopy)
  1915. $copyObj->setNew(true);
  1916. $copyObj->setIntId(NULL); // this is a auto-increment column, so set to default value
  1917. }
  1918. /**
  1919. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1920. * It creates a new object filling in the simple attributes, but skipping any primary
  1921. * keys that are defined for the table.
  1922. *
  1923. * If desired, this method can also make copies of all associated (fkey referrers)
  1924. * objects.
  1925. *
  1926. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1927. * @return asset Clone of current object.
  1928. * @throws PropelException
  1929. */
  1930. public function copy($deepCopy = false)
  1931. {
  1932. // we use get_class(), because this might be a subclass
  1933. $clazz = get_class($this);
  1934. $copyObj = new $clazz();
  1935. $this->copyInto($copyObj, $deepCopy);
  1936. $copyObj->setCopiedFrom($this);
  1937. return $copyObj;
  1938. }
  1939. /**
  1940. * Stores the source object that this object copied from
  1941. *
  1942. * @var asset Clone of current object.
  1943. */
  1944. protected $copiedFrom = null;
  1945. /**
  1946. * Stores the source object that this object copied from
  1947. *
  1948. * @param asset $copiedFrom Clone of current object.
  1949. */
  1950. public function setCopiedFrom(asset $copiedFrom)
  1951. {
  1952. $this->copiedFrom = $copiedFrom;
  1953. }
  1954. /**
  1955. * Returns a peer instance associated with this om.
  1956. *
  1957. * Since Peer classes are not to have any instance attributes, this method returns the
  1958. * same instance for all member of this class. The method could therefore
  1959. * be static, but this would prevent one from overriding the behavior.
  1960. *
  1961. * @return assetPeer
  1962. */
  1963. public function getPeer()
  1964. {
  1965. if (self::$peer === null) {
  1966. self::$peer = new assetPeer();
  1967. }
  1968. return self::$peer;
  1969. }
  1970. /**
  1971. * Declares an association between this object and a entry object.
  1972. *
  1973. * @param entry $v
  1974. * @return asset The current object (for fluent API support)
  1975. * @throws PropelException
  1976. */
  1977. public function setentry(entry $v = null)
  1978. {
  1979. if ($v === null) {
  1980. $this->setEntryId(NULL);
  1981. } else {
  1982. $this->setEntryId($v->getId());
  1983. }
  1984. $this->aentry = $v;
  1985. // Add binding for other direction of this n:n relationship.
  1986. // If this object has already been added to the entry object, it will not be re-added.
  1987. if ($v !== null) {
  1988. $v->addasset($this);
  1989. }
  1990. return $this;
  1991. }
  1992. /**
  1993. * Get the associated entry object
  1994. *
  1995. * @param PropelPDO Optional Connection object.
  1996. * @return entry The associated entry object.
  1997. * @throws PropelException
  1998. */
  1999. public function getentry(PropelPDO $con = null)
  2000. {
  2001. if ($this->aentry === null && (($this->entry_id !== "" && $this->entry_id !== null))) {
  2002. $this->aentry = entryPeer::retrieveByPk($this->entry_id);
  2003. /* The following can be used additionally to
  2004. guarantee the related object contains a reference
  2005. to this object. This level of coupling may, however, be
  2006. undesirable since it could result in an only partially populated collection
  2007. in the referenced object.
  2008. $this->aentry->addassets($this);
  2009. */
  2010. }
  2011. return $this->aentry;
  2012. }
  2013. /**
  2014. * Declares an association between this object and a assetParams object.
  2015. *
  2016. * @param assetParams $v
  2017. * @return asset The current object (for fluent API support)
  2018. * @throws PropelException
  2019. */
  2020. public function setassetParams(assetParams $v = null)
  2021. {
  2022. if ($v === null) {
  2023. $this->setFlavorParamsId(NULL);
  2024. } else {
  2025. $this->setFlavorParamsId($v->getId());
  2026. }
  2027. $this->aassetParams = $v;
  2028. // Add binding for other direction of this n:n relationship.
  2029. // If this object has already been added to the assetParams object, it will not be re-added.
  2030. if ($v !== null) {
  2031. $v->addasset($this);
  2032. }
  2033. return $this;
  2034. }
  2035. /**
  2036. * Get the associated assetParams object
  2037. *
  2038. * @param PropelPDO Optional Connection object.
  2039. * @return assetParams The associated assetParams object.
  2040. * @throws PropelException
  2041. */
  2042. public function getassetParams(PropelPDO $con = null)
  2043. {
  2044. if ($this->aassetParams === null && ($this->flavor_params_id !== null)) {
  2045. $this->aassetParams = assetParamsPeer::retrieveByPk($this->flavor_params_id);
  2046. /* The following can be used additionally to
  2047. guarantee the related object contains a reference
  2048. to this object. This level of coupling may, however, be
  2049. undesirable since it could result in an only partially populated collection
  2050. in the referenced object.
  2051. $this->aassetParams->addassets($this);
  2052. */
  2053. }
  2054. return $this->aassetParams;
  2055. }
  2056. /**
  2057. * Clears out the collmediaInfos collection (array).
  2058. *
  2059. * This does not modify the database; however, it will remove any associated objects, causing
  2060. * them to be refetched by subsequent calls to accessor method.
  2061. *
  2062. * @return void
  2063. * @see addmediaInfos()
  2064. */
  2065. public function clearmediaInfos()
  2066. {
  2067. $this->collmediaInfos = null; // important to set this to NULL since that means it is uninitialized
  2068. }
  2069. /**
  2070. * Initializes the collmediaInfos collection (array).
  2071. *
  2072. * By default this just sets the collmediaInfos collection to an empty array (like clearcollmediaInfos());
  2073. * however, you may wish to override this method in your stub class to provide setting appropriate
  2074. * to your application -- for example, setting the initial array to the values stored in database.
  2075. *
  2076. * @return void
  2077. */
  2078. public function initmediaInfos()
  2079. {
  2080. $this->collmediaInfos = array();
  2081. }
  2082. /**
  2083. * Gets an array of mediaInfo objects which contain a foreign key that references this object.
  2084. *
  2085. * If this collection has already been initialized with an identical Criteria, it returns the collection.
  2086. * Otherwise if this asset has previously been saved, it will retrieve
  2087. * related mediaInfos from storage. If this asset is new, it will return
  2088. * an empty collection or the current collection, the criteria is ignored on a new object.
  2089. *
  2090. * @param PropelPDO $con
  2091. * @param Criteria $criteria
  2092. * @return array mediaInfo[]
  2093. * @throws PropelException
  2094. */
  2095. public function getmediaInfos($criteria = null, PropelPDO $con = null)
  2096. {
  2097. if ($criteria === null) {
  2098. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2099. }
  2100. elseif ($criteria instanceof Criteria)
  2101. {
  2102. $criteria = clone $criteria;
  2103. }
  2104. if ($this->collmediaInfos === null) {
  2105. if ($this->isNew()) {
  2106. $this->collmediaInfos = array();
  2107. } else {
  2108. $criteria->add(mediaInfoPeer::FLAVOR_ASSET_ID, $this->id);
  2109. mediaInfoPeer::addSelectColumns($criteria);
  2110. $this->collmediaInfos = mediaInfoPeer::doSelect($criteria, $con);
  2111. }
  2112. } else {
  2113. // criteria has no effect for a new object
  2114. if (!$this->isNew()) {
  2115. // the following code is to determine if a new query is
  2116. // called for. If the criteria is the same as the last
  2117. // one, just return the collection.
  2118. $criteria->add(mediaInfoPeer::FLAVOR_ASSET_ID, $this->id);
  2119. mediaInfoPeer::addSelectColumns($criteria);
  2120. if (!isset($this->lastmediaInfoCriteria) || !$this->lastmediaInfoCriteria->equals($criteria)) {
  2121. $this->collmediaInfos = mediaInfoPeer::doSelect($criteria, $con);
  2122. }
  2123. }
  2124. }
  2125. $this->lastmediaInfoCriteria = $criteria;
  2126. return $this->collmediaInfos;
  2127. }
  2128. /**
  2129. * Returns the number of related mediaInfo objects.
  2130. *
  2131. * @param Criteria $criteria
  2132. * @param boolean $distinct
  2133. * @param PropelPDO $con
  2134. * @return int Count of related mediaInfo objects.
  2135. * @throws PropelException
  2136. */
  2137. public function countmediaInfos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  2138. {
  2139. if ($criteria === null) {
  2140. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2141. } else {
  2142. $criteria = clone $criteria;
  2143. }
  2144. if ($distinct) {
  2145. $criteria->setDistinct();
  2146. }
  2147. $count = null;
  2148. if ($this->collmediaInfos === null) {
  2149. if ($this->isNew()) {
  2150. $count = 0;
  2151. } else {
  2152. $criteria->add(mediaInfoPeer::FLAVOR_ASSET_ID, $this->id);
  2153. $count = mediaInfoPeer::doCount($criteria, false, $con);
  2154. }
  2155. } else {
  2156. // criteria has no effect for a new object
  2157. if (!$this->isNew()) {
  2158. // the following code is to determine if a new query is
  2159. // called for. If the criteria is the same as the last
  2160. // one, just return count of the collection.
  2161. $criteria->add(mediaInfoPeer::FLAVOR_ASSET_ID, $this->id);
  2162. if (!isset($this->lastmediaInfoCriteria) || !$this->lastmediaInfoCriteria->equals($criteria)) {
  2163. $count = mediaInfoPeer::doCount($criteria, false, $con);
  2164. } else {
  2165. $count = count($this->collmediaInfos);
  2166. }
  2167. } else {
  2168. $count = count($this->collmediaInfos);
  2169. }
  2170. }
  2171. return $count;
  2172. }
  2173. /**
  2174. * Method called to associate a mediaInfo object to this object
  2175. * through the mediaInfo foreign key attribute.
  2176. *
  2177. * @param mediaInfo $l mediaInfo
  2178. * @return void
  2179. * @throws PropelException
  2180. */
  2181. public function addmediaInfo(mediaInfo $l)
  2182. {
  2183. if ($this->collmediaInfos === null) {
  2184. $this->initmediaInfos();
  2185. }
  2186. if (!in_array($l, $this->collmediaInfos, true)) { // only add it if the **same** object is not already associated
  2187. array_push($this->collmediaInfos, $l);
  2188. $l->setasset($this);
  2189. }
  2190. }
  2191. /**
  2192. * Clears out the collassetParamsOutputs collection (array).
  2193. *
  2194. * This does not modify the database; however, it will remove any associated objects, causing
  2195. * them to be refetched by subsequent calls to accessor method.
  2196. *
  2197. * @return void
  2198. * @see addassetParamsOutputs()
  2199. */
  2200. public function clearassetParamsOutputs()
  2201. {
  2202. $this->collassetParamsOutputs = null; // important to set this to NULL since that means it is uninitialized
  2203. }
  2204. /**
  2205. * Initializes the collassetParamsOutputs collection (array).
  2206. *
  2207. * By default this just sets the collassetParamsOutputs collection to an empty array (like clearcollassetParamsOutputs());
  2208. * however, you may wish to override this method in your stub class to provide setting appropriate
  2209. * to your application -- for example, setting the initial array to the values stored in database.
  2210. *
  2211. * @return void
  2212. */
  2213. public function initassetParamsOutputs()
  2214. {
  2215. $this->collassetParamsOutputs = array();
  2216. }
  2217. /**
  2218. * Gets an array of assetParamsOutput objects which contain a foreign key that references this object.
  2219. *
  2220. * If this collection has already been initialized with an identical Criteria, it returns the collection.
  2221. * Otherwise if this asset has previously been saved, it will retrieve
  2222. * related assetParamsOutputs from storage. If this asset is new, it will return
  2223. * an empty collection or the current collection, the criteria is ignored on a new object.
  2224. *
  2225. * @param PropelPDO $con
  2226. * @param Criteria $criteria
  2227. * @return array assetParamsOutput[]
  2228. * @throws PropelException
  2229. */
  2230. public function getassetParamsOutputs($criteria = null, PropelPDO $con = null)
  2231. {
  2232. if ($criteria === null) {
  2233. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2234. }
  2235. elseif ($criteria instanceof Criteria)
  2236. {
  2237. $criteria = clone $criteria;
  2238. }
  2239. if ($this->collassetParamsOutputs === null) {
  2240. if ($this->isNew()) {
  2241. $this->collassetParamsOutputs = array();
  2242. } else {
  2243. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2244. assetParamsOutputPeer::addSelectColumns($criteria);
  2245. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelect($criteria, $con);
  2246. }
  2247. } else {
  2248. // criteria has no effect for a new object
  2249. if (!$this->isNew()) {
  2250. // the following code is to determine if a new query is
  2251. // called for. If the criteria is the same as the last
  2252. // one, just return the collection.
  2253. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2254. assetParamsOutputPeer::addSelectColumns($criteria);
  2255. if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
  2256. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelect($criteria, $con);
  2257. }
  2258. }
  2259. }
  2260. $this->lastassetParamsOutputCriteria = $criteria;
  2261. return $this->collassetParamsOutputs;
  2262. }
  2263. /**
  2264. * Returns the number of related assetParamsOutput objects.
  2265. *
  2266. * @param Criteria $criteria
  2267. * @param boolean $distinct
  2268. * @param PropelPDO $con
  2269. * @return int Count of related assetParamsOutput objects.
  2270. * @throws PropelException
  2271. */
  2272. public function countassetParamsOutputs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  2273. {
  2274. if ($criteria === null) {
  2275. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2276. } else {
  2277. $criteria = clone $criteria;
  2278. }
  2279. if ($distinct) {
  2280. $criteria->setDistinct();
  2281. }
  2282. $count = null;
  2283. if ($this->collassetParamsOutputs === null) {
  2284. if ($this->isNew()) {
  2285. $count = 0;
  2286. } else {
  2287. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2288. $count = assetParamsOutputPeer::doCount($criteria, false, $con);
  2289. }
  2290. } else {
  2291. // criteria has no effect for a new object
  2292. if (!$this->isNew()) {
  2293. // the following code is to determine if a new query is
  2294. // called for. If the criteria is the same as the last
  2295. // one, just return count of the collection.
  2296. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2297. if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
  2298. $count = assetParamsOutputPeer::doCount($criteria, false, $con);
  2299. } else {
  2300. $count = count($this->collassetParamsOutputs);
  2301. }
  2302. } else {
  2303. $count = count($this->collassetParamsOutputs);
  2304. }
  2305. }
  2306. return $count;
  2307. }
  2308. /**
  2309. * Method called to associate a assetParamsOutput object to this object
  2310. * through the assetParamsOutput foreign key attribute.
  2311. *
  2312. * @param assetParamsOutput $l assetParamsOutput
  2313. * @return void
  2314. * @throws PropelException
  2315. */
  2316. public function addassetParamsOutput(assetParamsOutput $l)
  2317. {
  2318. if ($this->collassetParamsOutputs === null) {
  2319. $this->initassetParamsOutputs();
  2320. }
  2321. if (!in_array($l, $this->collassetParamsOutputs, true)) { // only add it if the **same** object is not already associated
  2322. array_push($this->collassetParamsOutputs, $l);
  2323. $l->setasset($this);
  2324. }
  2325. }
  2326. /**
  2327. * If this collection has already been initialized with
  2328. * an identical criteria, it returns the collection.
  2329. * Otherwise if this asset is new, it will return
  2330. * an empty collection; or if this asset has previously
  2331. * been saved, it will retrieve related assetParamsOutputs from storage.
  2332. *
  2333. * This method is protected by default in order to keep the public
  2334. * api reasonable. You can provide public methods for those you
  2335. * actually need in asset.
  2336. */
  2337. public function getassetParamsOutputsJoinassetParams($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  2338. {
  2339. if ($criteria === null) {
  2340. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2341. }
  2342. elseif ($criteria instanceof Criteria)
  2343. {
  2344. $criteria = clone $criteria;
  2345. }
  2346. if ($this->collassetParamsOutputs === null) {
  2347. if ($this->isNew()) {
  2348. $this->collassetParamsOutputs = array();
  2349. } else {
  2350. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2351. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinassetParams($criteria, $con, $join_behavior);
  2352. }
  2353. } else {
  2354. // the following code is to determine if a new query is
  2355. // called for. If the criteria is the same as the last
  2356. // one, just return the collection.
  2357. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2358. if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
  2359. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinassetParams($criteria, $con, $join_behavior);
  2360. }
  2361. }
  2362. $this->lastassetParamsOutputCriteria = $criteria;
  2363. return $this->collassetParamsOutputs;
  2364. }
  2365. /**
  2366. * If this collection has already been initialized with
  2367. * an identical criteria, it returns the collection.
  2368. * Otherwise if this asset is new, it will return
  2369. * an empty collection; or if this asset has previously
  2370. * been saved, it will retrieve related assetParamsOutputs from storage.
  2371. *
  2372. * This method is protected by default in order to keep the public
  2373. * api reasonable. You can provide public methods for those you
  2374. * actually need in asset.
  2375. */
  2376. public function getassetParamsOutputsJoinentry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  2377. {
  2378. if ($criteria === null) {
  2379. $criteria = new Criteria(assetPeer::DATABASE_NAME);
  2380. }
  2381. elseif ($criteria instanceof Criteria)
  2382. {
  2383. $criteria = clone $criteria;
  2384. }
  2385. if ($this->collassetParamsOutputs === null) {
  2386. if ($this->isNew()) {
  2387. $this->collassetParamsOutputs = array();
  2388. } else {
  2389. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2390. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinentry($criteria, $con, $join_behavior);
  2391. }
  2392. } else {
  2393. // the following code is to determine if a new query is
  2394. // called for. If the criteria is the same as the last
  2395. // one, just return the collection.
  2396. $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
  2397. if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
  2398. $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinentry($criteria, $con, $join_behavior);
  2399. }
  2400. }
  2401. $this->lastassetParamsOutputCriteria = $criteria;
  2402. return $this->collassetParamsOutputs;
  2403. }
  2404. /**
  2405. * Resets all collections of referencing foreign keys.
  2406. *
  2407. * This method is a user-space workaround for PHP's inability to garbage collect objects
  2408. * with circular references. This is currently necessary when using Propel in certain
  2409. * daemon or large-volumne/high-memory operations.
  2410. *
  2411. * @param boolean $deep Whether to also clear the references on all associated objects.
  2412. */
  2413. public function clearAllReferences($deep = false)
  2414. {
  2415. if ($deep) {
  2416. if ($this->collmediaInfos) {
  2417. foreach ((array) $this->collmediaInfos as $o) {
  2418. $o->clearAllReferences($deep);
  2419. }
  2420. }
  2421. if ($this->collassetParamsOutputs) {
  2422. foreach ((array) $this->collassetParamsOutputs as $o) {
  2423. $o->clearAllReferences($deep);
  2424. }
  2425. }
  2426. } // if ($deep)
  2427. $this->collmediaInfos = null;
  2428. $this->collassetParamsOutputs = null;
  2429. $this->aentry = null;
  2430. $this->aassetParams = null;
  2431. }
  2432. /* ---------------------- CustomData functions ------------------------- */
  2433. /**
  2434. * @var myCustomData
  2435. */
  2436. protected $m_custom_data = null;
  2437. /**
  2438. * Store custom data old values before the changes
  2439. * @var array
  2440. */
  2441. protected $oldCustomDataValues = array();
  2442. /**
  2443. * @return array
  2444. */
  2445. public function getCustomDataOldValues()
  2446. {
  2447. return $this->oldCustomDataValues;
  2448. }
  2449. /**
  2450. * @param string $name
  2451. * @param string $value
  2452. * @param string $namespace
  2453. * @return string
  2454. */
  2455. public function putInCustomData ( $name , $value , $namespace = null )
  2456. {
  2457. $customData = $this->getCustomDataObj( );
  2458. $currentNamespace = '';
  2459. if($namespace)
  2460. $currentNamespace = $namespace;
  2461. if(!isset($this->oldCustomDataValues[$currentNamespace]))
  2462. $this->oldCustomDataValues[$currentNamespace] = array();
  2463. if(!isset($this->oldCustomDataValues[$currentNamespace][$name]))
  2464. $this->oldCustomDataValues[$currentNamespace][$name] = $customData->get($name, $namespace);
  2465. $customData->put ( $name , $value , $namespace );
  2466. }
  2467. /**
  2468. * @param string $name
  2469. * @param string $namespace
  2470. * @param string $defaultValue
  2471. * @return string
  2472. */
  2473. public function getFromCustomData ( $name , $namespace = null , $defaultValue = null )
  2474. {
  2475. $customData = $this->getCustomDataObj( );
  2476. $res = $customData->get ( $name , $namespace );
  2477. if ( $res === null ) return $defaultValue;
  2478. return $res;
  2479. }
  2480. /**
  2481. * @param string $name
  2482. * @param string $namespace
  2483. */
  2484. public function removeFromCustomData ( $name , $namespace = null)
  2485. {
  2486. $customData = $this->getCustomDataObj( );
  2487. return $customData->remove ( $name , $namespace );
  2488. }
  2489. /**
  2490. * @param string $name
  2491. * @param int $delta
  2492. * @param string $namespace
  2493. * @return string
  2494. */
  2495. public function incInCustomData ( $name , $delta = 1, $namespace = null)
  2496. {
  2497. $customData = $this->getCustomDataObj( );
  2498. return $customData->inc ( $name , $delta , $namespace );
  2499. }
  2500. /**
  2501. * @param string $name
  2502. * @param int $delta
  2503. * @param string $namespace
  2504. * @return string
  2505. */
  2506. public function decInCustomData ( $name , $delta = 1, $namespace = null)
  2507. {
  2508. $customData = $this->getCustomDataObj( );
  2509. return $customData->dec ( $name , $delta , $namespace );
  2510. }
  2511. /**
  2512. * @return myCustomData
  2513. */
  2514. public function getCustomDataObj( )
  2515. {
  2516. if ( ! $this->m_custom_data )
  2517. {
  2518. $this->m_custom_data = myCustomData::fromString ( $this->getCustomData() );
  2519. }
  2520. return $this->m_custom_data;
  2521. }
  2522. /**
  2523. * Must be called before saving the object
  2524. */
  2525. public function setCustomDataObj()
  2526. {
  2527. if ( $this->m_custom_data != null )
  2528. {
  2529. $this->setCustomData( $this->m_custom_data->toString() );
  2530. }
  2531. }
  2532. /* ---------------------- CustomData functions ------------------------- */
  2533. } // Baseasset