CC-3174 : showbuilder

changing playlist table to remove unused columns, adding foreign key to user, adding aggregate length column.
This commit is contained in:
Naomi Aro 2012-02-04 21:26:21 +01:00
parent 38f3d6bfb0
commit e8f2506474
18 changed files with 416 additions and 459 deletions

View file

@ -95,7 +95,7 @@ class PlaylistController extends Zend_Controller_Action
$pl = new Application_Model_Playlist();
$pl->setName("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->login);
$pl->setPLMetaData('dc:creator', $userInfo->id);
$this->changePlaylist($pl->getId());
$this->createFullResponse($pl);

View file

@ -23,11 +23,6 @@ class Application_Model_Playlist {
*/
private $pl;
/**
* MetaData
*/
public $md;
/**
* info needed to insert a new playlist element.
*/
@ -44,9 +39,9 @@ class Application_Model_Playlist {
//using propel's phpNames.
private $categories = array(
"dc:title" => "DbName",
"dc:creator" => "DbCreator",
"dc:creator" => "DbCreatorId",
"dc:description" => "DbDescription",
"dcterms:extent" => "length"
"dcterms:extent" => "getDbLength"
);
@ -61,8 +56,7 @@ class Application_Model_Playlist {
}
else {
$this->pl = new CcPlaylist();
$this->pl->setDbState('ready');
$this->pl->setDbUtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbUTime("now", new DateTimeZone("UTC"));
$this->pl->save();
}
@ -158,19 +152,9 @@ class Application_Model_Playlist {
return $files;
}
//TODO make another aggregate column for playlist length.
//aggregate column on playlistcontents cliplength column.
public function getLength() {
/*
$res = CcPlaylistQuery::create()
->findPK($this->id)
->computeLength();
if (is_null($res)) {
$res = '00:00:00';
}
*/
return '00:00:00';
$this->pl->getDbLength();
}
@ -239,7 +223,25 @@ class Application_Model_Playlist {
}
else {
$pos = ($addType == 'after') ? $this->getSize() : 0;
//add to the end of the playlist
if ($addType == 'after') {
$pos = $this->getSize();
}
//add to the beginning of the playlist.
else {
$pos = 0;
$contentsToUpdate = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->orderByDbPosition()
->find($this->con);
}
$contentsToUpdate = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($pos, Criteria::GREATER_EQUAL)
->orderByDbPosition()
->find($this->con);
Logging::log("Adding to playlist");
Logging::log("at position {$pos}");
@ -596,11 +598,6 @@ class Application_Model_Playlist {
$md = array();
foreach($categories as $key => $val) {
if($val === 'length') {
$md[$key] = $this->getLength();
continue;
}
$method = 'get' . $val;
$md[$key] = $this->pl->$method();
}
@ -611,11 +608,6 @@ class Application_Model_Playlist {
public function getPLMetaData($category)
{
$cat = $this->categories[$category];
if($cat === 'length') {
return $this->getLength();
}
$method = 'get' . $cat;
return $this->pl->$method();
}

View file

@ -687,11 +687,11 @@ class Application_Model_StoredFile {
$plSelect .= "'playlist' AS ".$key.", ";
$fileSelect .= $key.", ";
} else if ($key === "artist_name") {
$plSelect .= "creator AS ".$key.", ";
$plSelect .= "login AS ".$key.", ";
$fileSelect .= $key.", ";
} else if ($key === "length") {
$plSelect .= $key.", ";
$fileSelect .= $key.", ";
$fileSelect .= $key."::interval, ";
} else if ($key === "year") {
$plSelect .= "CAST(utime AS varchar) AS ".$key.", ";
$fileSelect .= $key.", ";
@ -708,8 +708,7 @@ class Application_Model_StoredFile {
}
$fromTable = " ((".$plSelect."PL.id
FROM ".$CC_CONFIG["playListTable"]." AS PL
LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))
UNION
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
@ -825,7 +824,7 @@ class Application_Model_StoredFile {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
//Logging::log($sql);
Logging::log($sql);
$results = $CC_DBC->getAll($sql);

View file

@ -40,14 +40,12 @@ class CcPlaylistTableMap extends TableMap {
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, '');
$this->addColumn('STATE', 'DbState', 'VARCHAR', true, 128, 'empty');
$this->addColumn('CURRENTLYACCESSING', 'DbCurrentlyaccessing', 'INTEGER', true, null, 0);
$this->addForeignKey('EDITEDBY', 'DbEditedby', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('LPTIME', 'DbLPtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('CREATOR', 'DbCreator', 'VARCHAR', false, 32, null);
$this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00');
// validators
} // initialize()
@ -56,8 +54,21 @@ class CcPlaylistTableMap extends TableMap {
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null);
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), null, null);
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'aggregate_column' => array('name' => 'length', 'expression' => 'SUM(cliplength)', 'foreign_table' => 'cc_playlistcontents', ),
);
} // getBehaviors()
} // CcPlaylistTableMap

View file

@ -59,4 +59,17 @@ class CcPlaylistcontentsTableMap extends TableMap {
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'aggregate_column_relation' => array('foreign_table' => 'cc_playlist', 'update_method' => 'updateDbLength', ),
);
} // getBehaviors()
} // CcPlaylistcontentsTableMap

View file

@ -62,7 +62,7 @@ class CcSubjsTableMap extends TableMap {
$this->addRelation('CcFiles', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null);
$this->addRelation('CcPerms', 'CcPerms', RelationMap::ONE_TO_MANY, array('id' => 'subj', ), 'CASCADE', null);
$this->addRelation('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'subjs_id', ), 'CASCADE', null);
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null);
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), null, null);
$this->addRelation('CcPref', 'CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null);
$this->addRelation('CcSess', 'CcSess', RelationMap::ONE_TO_MANY, array('id' => 'userid', ), 'CASCADE', null);
$this->addRelation('CcSubjsToken', 'CcSubjsToken', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), 'CASCADE', null);

View file

@ -37,26 +37,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $name;
/**
* The value for the state field.
* Note: this column has a database default value of: 'empty'
* @var string
*/
protected $state;
/**
* The value for the currentlyaccessing field.
* Note: this column has a database default value of: 0
* @var int
*/
protected $currentlyaccessing;
/**
* The value for the editedby field.
* @var int
*/
protected $editedby;
/**
* The value for the mtime field.
* @var string
@ -76,10 +56,10 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
protected $lptime;
/**
* The value for the creator field.
* @var string
* The value for the creator_id field.
* @var int
*/
protected $creator;
protected $creator_id;
/**
* The value for the description field.
@ -87,6 +67,13 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $description;
/**
* The value for the length field.
* Note: this column has a database default value of: '00:00:00'
* @var string
*/
protected $length;
/**
* @var CcSubjs
*/
@ -120,8 +107,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
public function applyDefaultValues()
{
$this->name = '';
$this->state = 'empty';
$this->currentlyaccessing = 0;
$this->length = '00:00:00';
}
/**
@ -154,36 +140,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->name;
}
/**
* Get the [state] column value.
*
* @return string
*/
public function getDbState()
{
return $this->state;
}
/**
* Get the [currentlyaccessing] column value.
*
* @return int
*/
public function getDbCurrentlyaccessing()
{
return $this->currentlyaccessing;
}
/**
* Get the [editedby] column value.
*
* @return int
*/
public function getDbEditedby()
{
return $this->editedby;
}
/**
* Get the [optionally formatted] temporal [mtime] column value.
*
@ -284,13 +240,13 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
/**
* Get the [creator] column value.
* Get the [creator_id] column value.
*
* @return string
* @return int
*/
public function getDbCreator()
public function getDbCreatorId()
{
return $this->creator;
return $this->creator_id;
}
/**
@ -303,6 +259,16 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->description;
}
/**
* Get the [length] column value.
*
* @return string
*/
public function getDbLength()
{
return $this->length;
}
/**
* Set the value of [id] column.
*
@ -343,70 +309,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbName()
/**
* Set the value of [state] column.
*
* @param string $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbState($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->state !== $v || $this->isNew()) {
$this->state = $v;
$this->modifiedColumns[] = CcPlaylistPeer::STATE;
}
return $this;
} // setDbState()
/**
* Set the value of [currentlyaccessing] column.
*
* @param int $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbCurrentlyaccessing($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->currentlyaccessing !== $v || $this->isNew()) {
$this->currentlyaccessing = $v;
$this->modifiedColumns[] = CcPlaylistPeer::CURRENTLYACCESSING;
}
return $this;
} // setDbCurrentlyaccessing()
/**
* Set the value of [editedby] column.
*
* @param int $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbEditedby($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->editedby !== $v) {
$this->editedby = $v;
$this->modifiedColumns[] = CcPlaylistPeer::EDITEDBY;
}
if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) {
$this->aCcSubjs = null;
}
return $this;
} // setDbEditedby()
/**
* Sets the value of [mtime] column to a normalized version of the date/time value specified.
*
@ -555,24 +457,28 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
} // setDbLPtime()
/**
* Set the value of [creator] column.
* Set the value of [creator_id] column.
*
* @param string $v new value
* @param int $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbCreator($v)
public function setDbCreatorId($v)
{
if ($v !== null) {
$v = (string) $v;
$v = (int) $v;
}
if ($this->creator !== $v) {
$this->creator = $v;
$this->modifiedColumns[] = CcPlaylistPeer::CREATOR;
if ($this->creator_id !== $v) {
$this->creator_id = $v;
$this->modifiedColumns[] = CcPlaylistPeer::CREATOR_ID;
}
if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) {
$this->aCcSubjs = null;
}
return $this;
} // setDbCreator()
} // setDbCreatorId()
/**
* Set the value of [description] column.
@ -594,6 +500,26 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbDescription()
/**
* Set the value of [length] column.
*
* @param string $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbLength($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->length !== $v || $this->isNew()) {
$this->length = $v;
$this->modifiedColumns[] = CcPlaylistPeer::LENGTH;
}
return $this;
} // setDbLength()
/**
* Indicates whether the columns in this object are only set to default values.
*
@ -608,11 +534,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return false;
}
if ($this->state !== 'empty') {
return false;
}
if ($this->currentlyaccessing !== 0) {
if ($this->length !== '00:00:00') {
return false;
}
@ -640,14 +562,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->state = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->currentlyaccessing = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
$this->editedby = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
$this->mtime = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->utime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->lptime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->creator = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->description = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->lptime = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->description = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->length = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->resetModified();
$this->setNew(false);
@ -656,7 +576,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 10; // 10 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 8; // 8 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcPlaylist object", $e);
@ -679,7 +599,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
public function ensureConsistency()
{
if ($this->aCcSubjs !== null && $this->editedby !== $this->aCcSubjs->getDbId()) {
if ($this->aCcSubjs !== null && $this->creator_id !== $this->aCcSubjs->getDbId()) {
$this->aCcSubjs = null;
}
} // ensureConsistency
@ -1008,29 +928,23 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->getDbName();
break;
case 2:
return $this->getDbState();
break;
case 3:
return $this->getDbCurrentlyaccessing();
break;
case 4:
return $this->getDbEditedby();
break;
case 5:
return $this->getDbMtime();
break;
case 6:
case 3:
return $this->getDbUtime();
break;
case 7:
case 4:
return $this->getDbLPtime();
break;
case 8:
return $this->getDbCreator();
case 5:
return $this->getDbCreatorId();
break;
case 9:
case 6:
return $this->getDbDescription();
break;
case 7:
return $this->getDbLength();
break;
default:
return null;
break;
@ -1057,14 +971,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$result = array(
$keys[0] => $this->getDbId(),
$keys[1] => $this->getDbName(),
$keys[2] => $this->getDbState(),
$keys[3] => $this->getDbCurrentlyaccessing(),
$keys[4] => $this->getDbEditedby(),
$keys[5] => $this->getDbMtime(),
$keys[6] => $this->getDbUtime(),
$keys[7] => $this->getDbLPtime(),
$keys[8] => $this->getDbCreator(),
$keys[9] => $this->getDbDescription(),
$keys[2] => $this->getDbMtime(),
$keys[3] => $this->getDbUtime(),
$keys[4] => $this->getDbLPtime(),
$keys[5] => $this->getDbCreatorId(),
$keys[6] => $this->getDbDescription(),
$keys[7] => $this->getDbLength(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
@ -1108,29 +1020,23 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->setDbName($value);
break;
case 2:
$this->setDbState($value);
break;
case 3:
$this->setDbCurrentlyaccessing($value);
break;
case 4:
$this->setDbEditedby($value);
break;
case 5:
$this->setDbMtime($value);
break;
case 6:
case 3:
$this->setDbUtime($value);
break;
case 7:
case 4:
$this->setDbLPtime($value);
break;
case 8:
$this->setDbCreator($value);
case 5:
$this->setDbCreatorId($value);
break;
case 9:
case 6:
$this->setDbDescription($value);
break;
case 7:
$this->setDbLength($value);
break;
} // switch()
}
@ -1157,14 +1063,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbState($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbCurrentlyaccessing($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbEditedby($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbMtime($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbUtime($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbLPtime($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbCreator($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbDescription($arr[$keys[9]]);
if (array_key_exists($keys[2], $arr)) $this->setDbMtime($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbLPtime($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbDescription($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbLength($arr[$keys[7]]);
}
/**
@ -1178,14 +1082,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if ($this->isColumnModified(CcPlaylistPeer::ID)) $criteria->add(CcPlaylistPeer::ID, $this->id);
if ($this->isColumnModified(CcPlaylistPeer::NAME)) $criteria->add(CcPlaylistPeer::NAME, $this->name);
if ($this->isColumnModified(CcPlaylistPeer::STATE)) $criteria->add(CcPlaylistPeer::STATE, $this->state);
if ($this->isColumnModified(CcPlaylistPeer::CURRENTLYACCESSING)) $criteria->add(CcPlaylistPeer::CURRENTLYACCESSING, $this->currentlyaccessing);
if ($this->isColumnModified(CcPlaylistPeer::EDITEDBY)) $criteria->add(CcPlaylistPeer::EDITEDBY, $this->editedby);
if ($this->isColumnModified(CcPlaylistPeer::MTIME)) $criteria->add(CcPlaylistPeer::MTIME, $this->mtime);
if ($this->isColumnModified(CcPlaylistPeer::UTIME)) $criteria->add(CcPlaylistPeer::UTIME, $this->utime);
if ($this->isColumnModified(CcPlaylistPeer::LPTIME)) $criteria->add(CcPlaylistPeer::LPTIME, $this->lptime);
if ($this->isColumnModified(CcPlaylistPeer::CREATOR)) $criteria->add(CcPlaylistPeer::CREATOR, $this->creator);
if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length);
return $criteria;
}
@ -1248,14 +1150,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDbName($this->name);
$copyObj->setDbState($this->state);
$copyObj->setDbCurrentlyaccessing($this->currentlyaccessing);
$copyObj->setDbEditedby($this->editedby);
$copyObj->setDbMtime($this->mtime);
$copyObj->setDbUtime($this->utime);
$copyObj->setDbLPtime($this->lptime);
$copyObj->setDbCreator($this->creator);
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbDescription($this->description);
$copyObj->setDbLength($this->length);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@ -1323,9 +1223,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
public function setCcSubjs(CcSubjs $v = null)
{
if ($v === null) {
$this->setDbEditedby(NULL);
$this->setDbCreatorId(NULL);
} else {
$this->setDbEditedby($v->getDbId());
$this->setDbCreatorId($v->getDbId());
}
$this->aCcSubjs = $v;
@ -1349,8 +1249,8 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
public function getCcSubjs(PropelPDO $con = null)
{
if ($this->aCcSubjs === null && ($this->editedby !== null)) {
$this->aCcSubjs = CcSubjsQuery::create()->findPk($this->editedby, $con);
if ($this->aCcSubjs === null && ($this->creator_id !== null)) {
$this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
@ -1503,14 +1403,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
{
$this->id = null;
$this->name = null;
$this->state = null;
$this->currentlyaccessing = null;
$this->editedby = null;
$this->mtime = null;
$this->utime = null;
$this->lptime = null;
$this->creator = null;
$this->creator_id = null;
$this->description = null;
$this->length = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
@ -1543,6 +1441,34 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->aCcSubjs = null;
}
// aggregate_column behavior
/**
* Computes the value of the aggregate column length
*
* @param PropelPDO $con A connection object
*
* @return mixed The scalar result from the aggregate query
*/
public function computeDbLength(PropelPDO $con)
{
$stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_playlistcontents" WHERE cc_playlistcontents.PLAYLIST_ID = :p1');
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
/**
* Updates the aggregate column length
*
* @param PropelPDO $con A connection object
*/
public function updateDbLength(PropelPDO $con)
{
$this->setDbLength($this->computeDbLength($con));
$this->save($con);
}
/**
* Catches calls to virtual methods
*/

View file

@ -26,7 +26,7 @@ abstract class BaseCcPlaylistPeer {
const TM_CLASS = 'CcPlaylistTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 10;
const NUM_COLUMNS = 8;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -37,15 +37,6 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the NAME field */
const NAME = 'cc_playlist.NAME';
/** the column name for the STATE field */
const STATE = 'cc_playlist.STATE';
/** the column name for the CURRENTLYACCESSING field */
const CURRENTLYACCESSING = 'cc_playlist.CURRENTLYACCESSING';
/** the column name for the EDITEDBY field */
const EDITEDBY = 'cc_playlist.EDITEDBY';
/** the column name for the MTIME field */
const MTIME = 'cc_playlist.MTIME';
@ -55,12 +46,15 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the LPTIME field */
const LPTIME = 'cc_playlist.LPTIME';
/** the column name for the CREATOR field */
const CREATOR = 'cc_playlist.CREATOR';
/** the column name for the CREATOR_ID field */
const CREATOR_ID = 'cc_playlist.CREATOR_ID';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_playlist.DESCRIPTION';
/** the column name for the LENGTH field */
const LENGTH = 'cc_playlist.LENGTH';
/**
* An identiy map to hold any loaded instances of CcPlaylist objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@ -77,12 +71,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbCreator', 'DbDescription', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbCreator', 'dbDescription', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::UTIME, self::LPTIME, self::CREATOR, self::DESCRIPTION, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'UTIME', 'LPTIME', 'CREATOR', 'DESCRIPTION', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'utime', 'lptime', 'creator', 'description', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::LPTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'LPTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'lptime', 'creator_id', 'description', 'length', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@ -92,12 +86,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbState' => 2, 'DbCurrentlyaccessing' => 3, 'DbEditedby' => 4, 'DbMtime' => 5, 'DbUtime' => 6, 'DbLPtime' => 7, 'DbCreator' => 8, 'DbDescription' => 9, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbState' => 2, 'dbCurrentlyaccessing' => 3, 'dbEditedby' => 4, 'dbMtime' => 5, 'dbUtime' => 6, 'dbLPtime' => 7, 'dbCreator' => 8, 'dbDescription' => 9, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::STATE => 2, self::CURRENTLYACCESSING => 3, self::EDITEDBY => 4, self::MTIME => 5, self::UTIME => 6, self::LPTIME => 7, self::CREATOR => 8, self::DESCRIPTION => 9, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'STATE' => 2, 'CURRENTLYACCESSING' => 3, 'EDITEDBY' => 4, 'MTIME' => 5, 'UTIME' => 6, 'LPTIME' => 7, 'CREATOR' => 8, 'DESCRIPTION' => 9, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'state' => 2, 'currentlyaccessing' => 3, 'editedby' => 4, 'mtime' => 5, 'utime' => 6, 'lptime' => 7, 'creator' => 8, 'description' => 9, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbLPtime' => 4, 'DbCreatorId' => 5, 'DbDescription' => 6, 'DbLength' => 7, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbLPtime' => 4, 'dbCreatorId' => 5, 'dbDescription' => 6, 'dbLength' => 7, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::LPTIME => 4, self::CREATOR_ID => 5, self::DESCRIPTION => 6, self::LENGTH => 7, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'LPTIME' => 4, 'CREATOR_ID' => 5, 'DESCRIPTION' => 6, 'LENGTH' => 7, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'lptime' => 4, 'creator_id' => 5, 'description' => 6, 'length' => 7, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@ -171,25 +165,21 @@ abstract class BaseCcPlaylistPeer {
if (null === $alias) {
$criteria->addSelectColumn(CcPlaylistPeer::ID);
$criteria->addSelectColumn(CcPlaylistPeer::NAME);
$criteria->addSelectColumn(CcPlaylistPeer::STATE);
$criteria->addSelectColumn(CcPlaylistPeer::CURRENTLYACCESSING);
$criteria->addSelectColumn(CcPlaylistPeer::EDITEDBY);
$criteria->addSelectColumn(CcPlaylistPeer::MTIME);
$criteria->addSelectColumn(CcPlaylistPeer::UTIME);
$criteria->addSelectColumn(CcPlaylistPeer::LPTIME);
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR);
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID);
$criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION);
$criteria->addSelectColumn(CcPlaylistPeer::LENGTH);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
$criteria->addSelectColumn($alias . '.STATE');
$criteria->addSelectColumn($alias . '.CURRENTLYACCESSING');
$criteria->addSelectColumn($alias . '.EDITEDBY');
$criteria->addSelectColumn($alias . '.MTIME');
$criteria->addSelectColumn($alias . '.UTIME');
$criteria->addSelectColumn($alias . '.LPTIME');
$criteria->addSelectColumn($alias . '.CREATOR');
$criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.LENGTH');
}
}
@ -514,7 +504,7 @@ abstract class BaseCcPlaylistPeer {
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior);
$criteria->addJoin(CcPlaylistPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@ -550,7 +540,7 @@ abstract class BaseCcPlaylistPeer {
$startcol = (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS);
CcSubjsPeer::addSelectColumns($criteria);
$criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior);
$criteria->addJoin(CcPlaylistPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@ -630,7 +620,7 @@ abstract class BaseCcPlaylistPeer {
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior);
$criteria->addJoin(CcPlaylistPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@ -668,7 +658,7 @@ abstract class BaseCcPlaylistPeer {
CcSubjsPeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior);
$criteria->addJoin(CcPlaylistPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();

View file

@ -8,25 +8,21 @@
*
* @method CcPlaylistQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcPlaylistQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CcPlaylistQuery orderByDbState($order = Criteria::ASC) Order by the state column
* @method CcPlaylistQuery orderByDbCurrentlyaccessing($order = Criteria::ASC) Order by the currentlyaccessing column
* @method CcPlaylistQuery orderByDbEditedby($order = Criteria::ASC) Order by the editedby column
* @method CcPlaylistQuery orderByDbMtime($order = Criteria::ASC) Order by the mtime column
* @method CcPlaylistQuery orderByDbUtime($order = Criteria::ASC) Order by the utime column
* @method CcPlaylistQuery orderByDbLPtime($order = Criteria::ASC) Order by the lptime column
* @method CcPlaylistQuery orderByDbCreator($order = Criteria::ASC) Order by the creator column
* @method CcPlaylistQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column
* @method CcPlaylistQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcPlaylistQuery orderByDbLength($order = Criteria::ASC) Order by the length column
*
* @method CcPlaylistQuery groupByDbId() Group by the id column
* @method CcPlaylistQuery groupByDbName() Group by the name column
* @method CcPlaylistQuery groupByDbState() Group by the state column
* @method CcPlaylistQuery groupByDbCurrentlyaccessing() Group by the currentlyaccessing column
* @method CcPlaylistQuery groupByDbEditedby() Group by the editedby column
* @method CcPlaylistQuery groupByDbMtime() Group by the mtime column
* @method CcPlaylistQuery groupByDbUtime() Group by the utime column
* @method CcPlaylistQuery groupByDbLPtime() Group by the lptime column
* @method CcPlaylistQuery groupByDbCreator() Group by the creator column
* @method CcPlaylistQuery groupByDbCreatorId() Group by the creator_id column
* @method CcPlaylistQuery groupByDbDescription() Group by the description column
* @method CcPlaylistQuery groupByDbLength() Group by the length column
*
* @method CcPlaylistQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlaylistQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -45,25 +41,21 @@
*
* @method CcPlaylist findOneByDbId(int $id) Return the first CcPlaylist filtered by the id column
* @method CcPlaylist findOneByDbName(string $name) Return the first CcPlaylist filtered by the name column
* @method CcPlaylist findOneByDbState(string $state) Return the first CcPlaylist filtered by the state column
* @method CcPlaylist findOneByDbCurrentlyaccessing(int $currentlyaccessing) Return the first CcPlaylist filtered by the currentlyaccessing column
* @method CcPlaylist findOneByDbEditedby(int $editedby) Return the first CcPlaylist filtered by the editedby column
* @method CcPlaylist findOneByDbMtime(string $mtime) Return the first CcPlaylist filtered by the mtime column
* @method CcPlaylist findOneByDbUtime(string $utime) Return the first CcPlaylist filtered by the utime column
* @method CcPlaylist findOneByDbLPtime(string $lptime) Return the first CcPlaylist filtered by the lptime column
* @method CcPlaylist findOneByDbCreator(string $creator) Return the first CcPlaylist filtered by the creator column
* @method CcPlaylist findOneByDbCreatorId(int $creator_id) Return the first CcPlaylist filtered by the creator_id column
* @method CcPlaylist findOneByDbDescription(string $description) Return the first CcPlaylist filtered by the description column
* @method CcPlaylist findOneByDbLength(string $length) Return the first CcPlaylist filtered by the length column
*
* @method array findByDbId(int $id) Return CcPlaylist objects filtered by the id column
* @method array findByDbName(string $name) Return CcPlaylist objects filtered by the name column
* @method array findByDbState(string $state) Return CcPlaylist objects filtered by the state column
* @method array findByDbCurrentlyaccessing(int $currentlyaccessing) Return CcPlaylist objects filtered by the currentlyaccessing column
* @method array findByDbEditedby(int $editedby) Return CcPlaylist objects filtered by the editedby column
* @method array findByDbMtime(string $mtime) Return CcPlaylist objects filtered by the mtime column
* @method array findByDbUtime(string $utime) Return CcPlaylist objects filtered by the utime column
* @method array findByDbLPtime(string $lptime) Return CcPlaylist objects filtered by the lptime column
* @method array findByDbCreator(string $creator) Return CcPlaylist objects filtered by the creator column
* @method array findByDbCreatorId(int $creator_id) Return CcPlaylist objects filtered by the creator_id column
* @method array findByDbDescription(string $description) Return CcPlaylist objects filtered by the description column
* @method array findByDbLength(string $length) Return CcPlaylist objects filtered by the length column
*
* @package propel.generator.airtime.om
*/
@ -212,90 +204,6 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::NAME, $dbName, $comparison);
}
/**
* Filter the query on the state column
*
* @param string $dbState The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbState($dbState = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbState)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbState)) {
$dbState = str_replace('*', '%', $dbState);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistPeer::STATE, $dbState, $comparison);
}
/**
* Filter the query on the currentlyaccessing column
*
* @param int|array $dbCurrentlyaccessing The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbCurrentlyaccessing($dbCurrentlyaccessing = null, $comparison = null)
{
if (is_array($dbCurrentlyaccessing)) {
$useMinMax = false;
if (isset($dbCurrentlyaccessing['min'])) {
$this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbCurrentlyaccessing['max'])) {
$this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing, $comparison);
}
/**
* Filter the query on the editedby column
*
* @param int|array $dbEditedby The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbEditedby($dbEditedby = null, $comparison = null)
{
if (is_array($dbEditedby)) {
$useMinMax = false;
if (isset($dbEditedby['min'])) {
$this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbEditedby['max'])) {
$this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby, $comparison);
}
/**
* Filter the query on the mtime column
*
@ -390,25 +298,34 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
}
/**
* Filter the query on the creator column
* Filter the query on the creator_id column
*
* @param string $dbCreator The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param int|array $dbCreatorId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbCreator($dbCreator = null, $comparison = null)
public function filterByDbCreatorId($dbCreatorId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbCreator)) {
if (is_array($dbCreatorId)) {
$useMinMax = false;
if (isset($dbCreatorId['min'])) {
$this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbCreatorId['max'])) {
$this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbCreator)) {
$dbCreator = str_replace('*', '%', $dbCreator);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistPeer::CREATOR, $dbCreator, $comparison);
return $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId, $comparison);
}
/**
@ -433,6 +350,28 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::DESCRIPTION, $dbDescription, $comparison);
}
/**
* Filter the query on the length column
*
* @param string $dbLength The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbLength($dbLength = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbLength)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbLength)) {
$dbLength = str_replace('*', '%', $dbLength);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison);
}
/**
* Filter the query by a related CcSubjs object
*
@ -444,7 +383,7 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
public function filterByCcSubjs($ccSubjs, $comparison = null)
{
return $this
->addUsingAlias(CcPlaylistPeer::EDITEDBY, $ccSubjs->getDbId(), $comparison);
->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $ccSubjs->getDbId(), $comparison);
}
/**

View file

@ -107,6 +107,9 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
// aggregate_column_relation behavior
protected $oldCcPlaylist;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@ -895,6 +898,8 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
// aggregate_column_relation behavior
$this->updateRelatedCcPlaylist($con);
CcPlaylistcontentsPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@ -1437,6 +1442,10 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
*/
public function setCcPlaylist(CcPlaylist $v = null)
{
// aggregate_column_relation behavior
if (null !== $this->aCcPlaylist && $v !== $this->aCcPlaylist) {
$this->oldCcPlaylist = $this->aCcPlaylist;
}
if ($v === null) {
$this->setDbPlaylistId(NULL);
} else {
@ -1518,6 +1527,24 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
$this->aCcPlaylist = null;
}
// aggregate_column_relation behavior
/**
* Update the aggregate column in the related CcPlaylist object
*
* @param PropelPDO $con A connection object
*/
protected function updateRelatedCcPlaylist(PropelPDO $con)
{
if ($ccPlaylist = $this->getCcPlaylist()) {
$ccPlaylist->updateDbLength($con);
}
if ($this->oldCcPlaylist) {
$this->oldCcPlaylist->updateDbLength($con);
$this->oldCcPlaylist = null;
}
}
/**
* Catches calls to virtual methods
*/

View file

@ -578,4 +578,90 @@ abstract class BaseCcPlaylistcontentsQuery extends ModelCriteria
return $this;
}
/**
* Code to execute before every DELETE statement
*
* @param PropelPDO $con The connection object used by the query
*/
protected function basePreDelete(PropelPDO $con)
{
// aggregate_column_relation behavior
$this->findRelatedCcPlaylists($con);
return $this->preDelete($con);
}
/**
* Code to execute after every DELETE statement
*
* @param int $affectedRows the number of deleted rows
* @param PropelPDO $con The connection object used by the query
*/
protected function basePostDelete($affectedRows, PropelPDO $con)
{
// aggregate_column_relation behavior
$this->updateRelatedCcPlaylists($con);
return $this->postDelete($affectedRows, $con);
}
/**
* Code to execute before every UPDATE statement
*
* @param array $values The associatiove array of columns and values for the update
* @param PropelPDO $con The connection object used by the query
* @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
*/
protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
{
// aggregate_column_relation behavior
$this->findRelatedCcPlaylists($con);
return $this->preUpdate($values, $con, $forceIndividualSaves);
}
/**
* Code to execute after every UPDATE statement
*
* @param int $affectedRows the number of udated rows
* @param PropelPDO $con The connection object used by the query
*/
protected function basePostUpdate($affectedRows, PropelPDO $con)
{
// aggregate_column_relation behavior
$this->updateRelatedCcPlaylists($con);
return $this->postUpdate($affectedRows, $con);
}
// aggregate_column_relation behavior
/**
* Finds the related CcPlaylist objects and keep them for later
*
* @param PropelPDO $con A connection object
*/
protected function findRelatedCcPlaylists($con)
{
$criteria = clone $this;
if ($this->useAliasInSQL) {
$alias = $this->getModelAlias();
$criteria->removeAlias($alias);
} else {
$alias = '';
}
$this->ccPlaylists = CcPlaylistQuery::create()
->joinCcPlaylistcontents($alias)
->mergeWith($criteria)
->find($con);
}
protected function updateRelatedCcPlaylists($con)
{
foreach ($this->ccPlaylists as $ccPlaylist) {
$ccPlaylist->updateDbLength($con);
}
$this->ccPlaylists = array();
}
} // BaseCcPlaylistcontentsQuery

View file

@ -758,7 +758,7 @@ abstract class BaseCcSubjsQuery extends ModelCriteria
public function filterByCcPlaylist($ccPlaylist, $comparison = null)
{
return $this
->addUsingAlias(CcSubjsPeer::ID, $ccPlaylist->getDbEditedby(), $comparison);
->addUsingAlias(CcSubjsPeer::ID, $ccPlaylist->getDbCreatorId(), $comparison);
}
/**

View file

@ -1,6 +1,6 @@
#Note: project.home is automatically generated by the propel-install script.
#Any manual changes to this value will be overwritten.
project.home = /home/james/src/airtime/airtime_mvc
project.home = /home/naomiaro/airtime/airtime_mvc
project.build = ${project.home}/build
#Database driver

View file

@ -216,16 +216,19 @@
<table name="cc_playlist" phpName="CcPlaylist">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="name" phpName="DbName" type="VARCHAR" size="255" required="true" defaultValue=""/>
<column name="state" phpName="DbState" type="VARCHAR" size="128" required="true" defaultValue="empty"/>
<column name="currentlyaccessing" phpName="DbCurrentlyaccessing" type="INTEGER" required="true" defaultValue="0"/>
<column name="editedby" phpName="DbEditedby" type="INTEGER" required="false"/>
<column name="mtime" phpName="DbMtime" type="TIMESTAMP" size="6" required="false"/>
<column name="utime" phpName="DbUtime" type="TIMESTAMP" size="6" required="false"/>
<column name="lptime" phpName="DbLPtime" type="TIMESTAMP" size="6" required="false"/>
<column name="creator" phpName="DbCreator" type="VARCHAR" size="32" required="false"/>
<column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="false"/>
<column name="description" phpName="DbDescription" type="VARCHAR" size="512" required="false"/>
<foreign-key foreignTable="cc_subjs" name="cc_playlist_editedby_fkey">
<reference local="editedby" foreign="id"/>
<column name="length" phpName="DbLength" type="VARCHAR" sqlType="interval" defaultValue="00:00:00"/>
<behavior name="aggregate_column">
<parameter name="name" value="length" />
<parameter name="foreign_table" value="cc_playlistcontents" />
<parameter name="expression" value="SUM(cliplength)" />
</behavior>
<foreign-key foreignTable="cc_subjs" name="cc_playlist_createdby_fkey">
<reference local="creator_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_playlistcontents" phpName="CcPlaylistcontents">

View file

@ -288,14 +288,12 @@ CREATE TABLE "cc_playlist"
(
"id" serial NOT NULL,
"name" VARCHAR(255) default '' NOT NULL,
"state" VARCHAR(128) default 'empty' NOT NULL,
"currentlyaccessing" INTEGER default 0 NOT NULL,
"editedby" INTEGER,
"mtime" TIMESTAMP(6),
"utime" TIMESTAMP(6),
"lptime" TIMESTAMP(6),
"creator" VARCHAR(32),
"creator_id" INTEGER,
"description" VARCHAR(512),
"length" interval default '00:00:00',
PRIMARY KEY ("id")
);
@ -575,7 +573,7 @@ ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("sho
ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" FOREIGN KEY ("subjs_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_editedby_fkey" FOREIGN KEY ("editedby") REFERENCES "cc_subjs" ("id");
ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_createdby_fkey" FOREIGN KEY ("creator_id") REFERENCES "cc_subjs" ("id");
ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE;

View file

@ -3,26 +3,5 @@
----------------------------------------------------------------------------------
DROP FUNCTION calculate_position() CASCADE;
/* remove this trigger for group adds/delete */
/*
CREATE FUNCTION calculate_position() RETURNS trigger AS
'
BEGIN
IF(TG_OP=''INSERT'') THEN
UPDATE cc_playlistcontents SET position = (position + 1)
WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
END IF;
IF(TG_OP=''DELETE'') THEN
UPDATE cc_playlistcontents SET position = (position - 1)
WHERE (playlist_id = old.playlist_id AND position > old.position);
END IF;
RETURN NULL;
END;
'
LANGUAGE 'plpgsql';
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
FOR EACH ROW EXECUTE PROCEDURE calculate_position();
*/
--remove this trigger for group adds/delete

View file

@ -2,10 +2,4 @@
---cc_playlisttimes
-------------------------------------------------------
CREATE VIEW cc_playlisttimes AS
SELECT pl.id, COALESCE(t.length, '00:00:00'::time without time zone) AS length
FROM cc_playlist pl
LEFT JOIN ( SELECT cc_playlistcontents.playlist_id AS id,
sum(cc_playlistcontents.cliplength::interval)::time without time zone AS length
FROM cc_playlistcontents
GROUP BY cc_playlistcontents.playlist_id) t ON pl.id = t.id;
DROP VIEW cc_playlisttimes;

View file

@ -282,16 +282,7 @@ var AIRTIME = (function(AIRTIME){
.empty()
.append(json.html);
mod.setUpPlaylist();
}
function setPlaylistButtonEvents(el) {
$(el).delegate("#spl_new",
{"click": AIRTIME.playlist.fnNew});
$(el).delegate("#spl_delete",
{"click": AIRTIME.playlist.fnDelete});
setUpPlaylist();
}
//sets events dynamically for playlist entries (each row in the playlist)
@ -336,7 +327,7 @@ var AIRTIME = (function(AIRTIME){
"keydown": submitOnEnter});
}
mod.setUpPlaylist = function() {
function setUpPlaylist(playlist) {
var playlist = $("#side_playlist"),
sortableConf;
@ -478,11 +469,6 @@ var AIRTIME = (function(AIRTIME){
playlist.find("#spl_crossfade").removeClass("ui-state-active");
playlist.find("#crossfade_main").hide();
});
setPlaylistButtonEvents(playlist);
setPlaylistEntryEvents(playlist);
setCueEvents(playlist);
setFadeEvents(playlist);
sortableConf = (function(){
var origRow,
@ -530,8 +516,7 @@ var AIRTIME = (function(AIRTIME){
start: function(event, ui) {
ui.placeholder.html("PLACE HOLDER")
.width("99.5%")
.height(56)
.append('<div style="clear:both;"/>');
.height(56);
},
receive: fnReceive,
update: fnUpdate
@ -600,12 +585,27 @@ var AIRTIME = (function(AIRTIME){
});
};
mod.init = function() {
var playlist = $("#side_playlist");
$(playlist).delegate("#spl_new",
{"click": AIRTIME.playlist.fnNew});
$(playlist).delegate("#spl_delete",
{"click": AIRTIME.playlist.fnDelete});
setPlaylistEntryEvents(playlist);
setCueEvents(playlist);
setFadeEvents(playlist);
setUpPlaylist(playlist);
}
return AIRTIME;
}(AIRTIME || {}));
$(document).ready(function() {
AIRTIME.playlist.setUpPlaylist();
AIRTIME.playlist.init();
});