propel changes for playlist.

This commit is contained in:
naomiaro 2010-11-11 20:48:53 -05:00
parent f7dc117417
commit e1b6ee8d46
4 changed files with 66 additions and 67 deletions

View File

@ -67,7 +67,8 @@ class Playlist {
// Create the StoredPlaylist object // Create the StoredPlaylist object
$storedPlaylist = new Playlist(); $storedPlaylist = new Playlist();
$storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s"); $storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
$storedPlaylist->mtime = new DateTime("now"); $tz = ini_get('date.timezone');
$storedPlaylist->mtime = new DateTime("now", new DateTimeZone($tz));
$pl = new CcPlaylist(); $pl = new CcPlaylist();
$pl->setDbName($storedPlaylist->name); $pl->setDbName($storedPlaylist->name);
@ -131,7 +132,7 @@ class Playlist {
return FALSE; return FALSE;
$pl->setDbName($p_newname); $pl->setDbName($p_newname);
$pl->setDbMtime(new DateTime("now")); $pl->setDbMtime(new DateTime("now", new DateTimeZone(ini_get('date.timezone'))));
$pl->save(); $pl->save();
$this->name = $p_newname; $this->name = $p_newname;
@ -174,7 +175,7 @@ class Playlist {
return FALSE; return FALSE;
$pl->setDbState($p_state); $pl->setDbState($p_state);
$pl->setDbMtime(new DateTime("now")); $pl->setDbMtime(new DateTime("now", new DateTimeZone(ini_get('date.timezone'))));
$eb = (!is_null($p_editedby) ? $p_editedby : NULL); $eb = (!is_null($p_editedby) ? $p_editedby : NULL);
$pl->setDbEditedby($eb); $pl->setDbEditedby($eb);
@ -929,12 +930,14 @@ class Playlist {
$row->setDbPlaylistId($plId); $row->setDbPlaylistId($plId);
$row->setDbFileId($fileId); $row->setDbFileId($fileId);
$row->setDbPosition($pos); $row->setDbPosition($pos);
$row->save();
$row->setDbCliplength($clipLength); $row->setDbCliplength($clipLength);
$row->setDbCuein($cuein); $row->setDbCuein($cuein);
$row->setDbCueout($cueout); $row->setDbCueout($cueout);
$row->setDbFadein($fadeIn); $row->setDbFadein($fadeIn);
$row->setDbFadeout($fadeOut); $row->setDbFadeout($fadeOut);
$row->save();
return TRUE; return TRUE;
} }

View File

@ -16,14 +16,16 @@ require_once('Common.php');
class CcFiles extends BaseCcFiles { class CcFiles extends BaseCcFiles {
public function getDbLength() public function getDbLength()
{ {
return Common::getTimeInSub($this, 'LENGTH'); return $this->length;
} }
public function setDbLength($time) public function setDbLength($time)
{ {
return Common::setTimeInSub($this, 'LENGTH', $time); $this->length = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
return Common::setTimeInSub($this, 'LENGTH', $time);
}
} // CcFiles } // CcFiles

View File

@ -17,53 +17,63 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
public function getDbFadein() public function getDbFadein()
{ {
return Common::getTimeInSub($this, 'FADEIN'); return $this->fadein;
} }
public function setDbFadein($time) public function setDbFadein($time)
{ {
return Common::setTimeInSub($this, 'FADEIN', $time); $this->fadein = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
return Common::setTimeInSub($this, 'FADEIN', $time);
}
public function getDbFadeout() public function getDbFadeout()
{ {
return Common::getTimeInSub($this, 'FADEOUT'); return $this->fadeout;
} }
public function setDbFadeout($time) public function setDbFadeout($time)
{ {
return Common::setTimeInSub($this, 'FADEOUT', $time); $this->fadeout = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
return Common::setTimeInSub($this, 'FADEOUT', $time);
}
public function getDbCuein() public function getDbCuein()
{ {
return Common::getTimeInSub($this, 'CUEIN'); return $this->cuein;
} }
public function setDbCuein($time) public function setDbCuein($time)
{ {
return Common::setTimeInSub($this, 'CUEIN', $time); $this->cuein = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
return Common::setTimeInSub($this, 'CUEIN', $time);
}
public function getDbCueout() public function getDbCueout()
{ {
return Common::getTimeInSub($this, 'CUEOUT'); return $this->cueout;
} }
public function setDbCueout($time) public function setDbCueout($time)
{ {
return Common::setTimeInSub($this, 'CUEOUT', $time); $this->cueout = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
return Common::setTimeInSub($this, 'CUEOUT', $time);
}
public function getDbCliplength() public function getDbCliplength()
{ {
return Common::getTimeInSub($this, 'CLIPLENGTH'); return $this->cliplength;
} }
public function setDbCliplength($time) public function setDbCliplength($time)
{ {
return Common::setTimeInSub($this, 'CLIPLENGTH', $time); $this->cliplength = $time;
} //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
return Common::setTimeInSub($this, 'CLIPLENGTH', $time);
}

View File

@ -4,32 +4,16 @@ class Common {
public static function setTimeInSub($row, $col, $time) public static function setTimeInSub($row, $col, $time)
{ {
$class = get_class($row).'Peer'; $class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME); $con = Propel::getConnection($class::DATABASE_NAME);
$sql = 'UPDATE '.$class::TABLE_NAME $sql = 'UPDATE '.$class::TABLE_NAME
. ' SET '.$col.' = :f1' . ' SET '.$col.' = :f1'
. ' WHERE ' .$class::ID. ' = :p1'; . ' WHERE ' .$class::ID. ' = :p1';
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindValue(':f1', $time); $stmt->bindValue(':f1', $time);
$stmt->bindValue(':p1', $row->getDbId()); $stmt->bindValue(':p1', $row->getDbId());
$stmt->execute(); $stmt->execute();
} }
public static function getTimeInSub($row, $col)
{
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);
$sql = 'SELECT '.$col
. ' FROM '.$class::TABLE_NAME
. ' WHERE ' .$class::ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $row->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
} }