2012-07-25 18:44:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skeleton subclass for representing a row from the 'cc_block' 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 CcBlock extends BaseCcBlock
|
|
|
|
{
|
|
|
|
/**
|
2012-07-25 23:08:22 +02: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.
|
2012-07-25 23:08:22 +02:00
|
|
|
*
|
2021-10-11 16:10:47 +02:00
|
|
|
* @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-07-25 23:08:22 +02: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-07-25 23:08:22 +02: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-07-25 23:08:22 +02: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-07-25 23:08:22 +02:00
|
|
|
return strftime($format, $dt->format('U'));
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $dt->format($format);
|
2012-07-25 23:08:22 +02: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.
|
2012-07-25 23:08:22 +02:00
|
|
|
*
|
2021-10-11 16:10:47 +02:00
|
|
|
* @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-07-25 23:08:22 +02: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-07-25 23:08:22 +02: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-07-25 23:08:22 +02: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-07-25 23:08:22 +02:00
|
|
|
return strftime($format, $dt->format('U'));
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $dt->format($format);
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the value of the aggregate column length
|
2012-07-26 16:49:23 +02:00
|
|
|
* Overridden to provide a default of 00:00:00 if the block is empty.
|
2012-07-25 23:08:22 +02:00
|
|
|
*
|
|
|
|
* @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_blockcontents as bc
|
|
|
|
JOIN cc_files as f ON bc.file_id = f.id
|
|
|
|
WHERE BLOCK_ID = :b1
|
|
|
|
AND f.file_exists = true
|
|
|
|
SQL;
|
|
|
|
$stmt = $con->prepare($sql);
|
|
|
|
$stmt->bindValue(':b1', $this->getDbId());
|
2012-07-25 23:08:22 +02:00
|
|
|
$stmt->execute();
|
|
|
|
$length = $stmt->fetchColumn();
|
|
|
|
|
|
|
|
if (is_null($length)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$length = '00:00:00';
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
2012-07-25 18:44:37 +02:00
|
|
|
|
2012-07-25 23:08:22 +02:00
|
|
|
return $length;
|
|
|
|
}
|
2012-07-25 18:44:37 +02:00
|
|
|
} // CcBlock
|