2011-01-10 19:24:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skeleton subclass for representing a row from the 'cc_playlist' table.
|
|
|
|
*
|
|
|
|
* You should add additional methods to this class to meet the
|
|
|
|
* application requirements. This class will only be generated as
|
|
|
|
* long as it does not already exist in the output directory.
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
class CcPlaylist extends BaseCcPlaylist
|
|
|
|
{
|
2012-02-04 15:52:31 +01:00
|
|
|
/**
|
|
|
|
* Get the [optionally formatted] temporal [utime] column value.
|
|
|
|
*
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
|
|
* If format is NULL, then the raw DateTime object will be returned.
|
|
|
|
*
|
|
|
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
2022-09-12 13:16:14 +02:00
|
|
|
*
|
|
|
|
* @throws propelException - if unable to parse/validate the date/time value
|
2012-02-04 15:52:31 +01:00
|
|
|
*/
|
|
|
|
public function getDbUtime($format = 'Y-m-d H:i:s')
|
|
|
|
{
|
|
|
|
if ($this->utime === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-10-11 16:10:47 +02:00
|
|
|
$dt = new DateTime($this->utime, new DateTimeZone('UTC'));
|
2012-02-04 15:52:31 +01:00
|
|
|
} catch (Exception $x) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->utime, true), $x);
|
2012-02-04 15:52:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($format === null) {
|
|
|
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
|
|
return $dt;
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if (strpos($format, '%') !== false) {
|
2012-02-04 15:52:31 +01:00
|
|
|
return strftime($format, $dt->format('U'));
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $dt->format($format);
|
2012-02-04 15:52:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the [optionally formatted] temporal [mtime] column value.
|
|
|
|
*
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
|
|
* If format is NULL, then the raw DateTime object will be returned.
|
|
|
|
*
|
|
|
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
2022-09-12 13:16:14 +02:00
|
|
|
*
|
|
|
|
* @throws propelException - if unable to parse/validate the date/time value
|
2012-02-04 15:52:31 +01:00
|
|
|
*/
|
|
|
|
public function getDbMtime($format = 'Y-m-d H:i:s')
|
|
|
|
{
|
|
|
|
if ($this->mtime === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-10-11 16:10:47 +02:00
|
|
|
$dt = new DateTime($this->mtime, new DateTimeZone('UTC'));
|
2012-02-04 15:52:31 +01:00
|
|
|
} catch (Exception $x) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->mtime, true), $x);
|
2012-02-04 15:52:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($format === null) {
|
|
|
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
|
|
return $dt;
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if (strpos($format, '%') !== false) {
|
2012-02-04 15:52:31 +01:00
|
|
|
return strftime($format, $dt->format('U'));
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $dt->format($format);
|
2012-02-04 15:52:31 +01:00
|
|
|
}
|
2011-01-10 19:24:21 +01:00
|
|
|
|
2012-02-28 13:13:40 +01:00
|
|
|
/**
|
|
|
|
* Computes the value of the aggregate column length
|
|
|
|
* Overridden to provide a default of 00:00:00 if the playlist is empty.
|
|
|
|
*
|
|
|
|
* @param PropelPDO $con A connection object
|
|
|
|
*
|
|
|
|
* @return mixed The scalar result from the aggregate query
|
|
|
|
*/
|
|
|
|
public function computeDbLength(PropelPDO $con)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2012-11-06 16:58:25 +01:00
|
|
|
SELECT SUM(cliplength) FROM cc_playlistcontents as pc
|
2013-01-10 04:53:29 +01:00
|
|
|
LEFT JOIN cc_files as f ON pc.file_id = f.id
|
2012-11-06 16:58:25 +01:00
|
|
|
WHERE PLAYLIST_ID = :p1
|
2013-01-18 04:20:28 +01:00
|
|
|
AND (f.file_exists is NUll or f.file_exists = true)
|
2012-11-06 16:58:25 +01:00
|
|
|
SQL;
|
|
|
|
$stmt = $con->prepare($sql);
|
2012-02-28 13:13:40 +01:00
|
|
|
$stmt->bindValue(':p1', $this->getDbId());
|
|
|
|
$stmt->execute();
|
|
|
|
$length = $stmt->fetchColumn();
|
|
|
|
if (is_null($length)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$length = '00:00:00';
|
2012-02-28 13:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $length;
|
|
|
|
}
|
2011-01-10 19:24:21 +01:00
|
|
|
} // CcPlaylist
|