diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 734eef4ee..20b54deb8 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -101,8 +101,8 @@ class ScheduleGroup { $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); $id = $this->dateToId($p_datetime); $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] - ." (id, playlist_id, starts, ends, clip_length, group_id, file_id)" - ." VALUES ('$id', 0, TIMESTAMP '$p_datetime', " + ." (playlist_id, starts, ends, clip_length, group_id, file_id)" + ." VALUES (0, TIMESTAMP '$p_datetime', " ." (TIMESTAMP '$p_datetime' + INTERVAL '$length')," ." '$length'," ." {$this->groupId}, $p_audioFileId)"; @@ -143,9 +143,9 @@ class ScheduleGroup { $trackLength = $row["cliplength"]; //var_dump($trackLength); $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] - ." (id, instance_id, playlist_id, starts, ends, group_id, file_id," + ." (instance_id, playlist_id, starts, ends, group_id, file_id," ." clip_length, cue_in, cue_out, fade_in, fade_out)" - ." VALUES ($id, $show_instance, $p_playlistId, TIMESTAMP '$itemStartTime', " + ." VALUES ($show_instance, $p_playlistId, TIMESTAMP '$itemStartTime', " ." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength')," ." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}'," ." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')"; diff --git a/application/models/airtime/map/CcScheduleTableMap.php b/application/models/airtime/map/CcScheduleTableMap.php index 9bd987ad1..3f2502f1c 100644 --- a/application/models/airtime/map/CcScheduleTableMap.php +++ b/application/models/airtime/map/CcScheduleTableMap.php @@ -35,9 +35,10 @@ class CcScheduleTableMap extends TableMap { $this->setPhpName('CcSchedule'); $this->setClassname('CcSchedule'); $this->setPackage('airtime'); - $this->setUseIdGenerator(false); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_schedule_id_seq'); // columns - $this->addPrimaryKey('ID', 'DbId', 'BIGINT', true, null, null); + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); $this->addColumn('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', true, null, null); $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null); diff --git a/application/models/airtime/om/BaseCcSchedule.php b/application/models/airtime/om/BaseCcSchedule.php index bee75588e..2c8933840 100644 --- a/application/models/airtime/om/BaseCcSchedule.php +++ b/application/models/airtime/om/BaseCcSchedule.php @@ -26,7 +26,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent /** * The value for the id field. - * @var string + * @var int */ protected $id; @@ -164,7 +164,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent /** * Get the [id] column value. * - * @return string + * @return int */ public function getDbId() { @@ -465,13 +465,13 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent /** * Set the value of [id] column. * - * @param string $v new value + * @param int $v new value * @return CcSchedule The current object (for fluent API support) */ public function setDbId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } if ($this->id !== $v) { @@ -1014,7 +1014,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent { try { - $this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->playlist_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; $this->starts = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->ends = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; @@ -1224,13 +1224,21 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $this->setCcShowInstances($this->aCcShowInstances); } + if ($this->isNew() ) { + $this->modifiedColumns[] = CcSchedulePeer::ID; + } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $criteria = $this->buildCriteria(); + if ($criteria->keyContainsValue(CcSchedulePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSchedulePeer::ID.')'); + } + $pk = BasePeer::doInsert($criteria, $con); $affectedRows += 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += CcSchedulePeer::doUpdate($this, $con); @@ -1598,7 +1606,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent /** * Returns the primary key for this object (row). - * @return string + * @return int */ public function getPrimaryKey() { @@ -1608,7 +1616,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param string $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1637,7 +1645,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent */ public function copyInto($copyObj, $deepCopy = false) { - $copyObj->setDbId($this->id); $copyObj->setDbPlaylistId($this->playlist_id); $copyObj->setDbStarts($this->starts); $copyObj->setDbEnds($this->ends); @@ -1653,6 +1660,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $copyObj->setDbInstanceId($this->instance_id); $copyObj->setNew(true); + $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value } /** diff --git a/application/models/airtime/om/BaseCcSchedulePeer.php b/application/models/airtime/om/BaseCcSchedulePeer.php index f809b8239..d5a4e9afb 100644 --- a/application/models/airtime/om/BaseCcSchedulePeer.php +++ b/application/models/airtime/om/BaseCcSchedulePeer.php @@ -435,7 +435,7 @@ abstract class BaseCcSchedulePeer { */ public static function getPrimaryKeyFromRow($row, $startcol = 0) { - return (string) $row[$startcol]; + return (int) $row[$startcol]; } /** @@ -789,6 +789,10 @@ abstract class BaseCcSchedulePeer { $criteria = $values->buildCriteria(); // build Criteria from CcSchedule object } + if ($criteria->containsKey(CcSchedulePeer::ID) && $criteria->keyContainsValue(CcSchedulePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSchedulePeer::ID.')'); + } + // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); @@ -973,7 +977,7 @@ abstract class BaseCcSchedulePeer { /** * Retrieve a single object by pkey. * - * @param string $pk the primary key. + * @param int $pk the primary key. * @param PropelPDO $con the connection to use * @return CcSchedule */ diff --git a/application/models/airtime/om/BaseCcScheduleQuery.php b/application/models/airtime/om/BaseCcScheduleQuery.php index ccad9e4b8..73c237c69 100644 --- a/application/models/airtime/om/BaseCcScheduleQuery.php +++ b/application/models/airtime/om/BaseCcScheduleQuery.php @@ -47,7 +47,7 @@ * @method CcSchedule findOne(PropelPDO $con = null) Return the first CcSchedule matching the query * @method CcSchedule findOneOrCreate(PropelPDO $con = null) Return the first CcSchedule matching the query, or a new CcSchedule object populated from the query conditions when no match is found * - * @method CcSchedule findOneByDbId(string $id) Return the first CcSchedule filtered by the id column + * @method CcSchedule findOneByDbId(int $id) Return the first CcSchedule filtered by the id column * @method CcSchedule findOneByDbPlaylistId(int $playlist_id) Return the first CcSchedule filtered by the playlist_id column * @method CcSchedule findOneByDbStarts(string $starts) Return the first CcSchedule filtered by the starts column * @method CcSchedule findOneByDbEnds(string $ends) Return the first CcSchedule filtered by the ends column @@ -62,7 +62,7 @@ * @method CcSchedule findOneByDbMediaItemPlayed(boolean $media_item_played) Return the first CcSchedule filtered by the media_item_played column * @method CcSchedule findOneByDbInstanceId(int $instance_id) Return the first CcSchedule filtered by the instance_id column * - * @method array findByDbId(string $id) Return CcSchedule objects filtered by the id column + * @method array findByDbId(int $id) Return CcSchedule objects filtered by the id column * @method array findByDbPlaylistId(int $playlist_id) Return CcSchedule objects filtered by the playlist_id column * @method array findByDbStarts(string $starts) Return CcSchedule objects filtered by the starts column * @method array findByDbEnds(string $ends) Return CcSchedule objects filtered by the ends column @@ -188,7 +188,7 @@ abstract class BaseCcScheduleQuery extends ModelCriteria /** * Filter the query on the id column * - * @param string|array $dbId The value to use as filter. + * @param int|array $dbId 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 * diff --git a/build/schema.xml b/build/schema.xml index dcebdfc67..ee1d4dde0 100644 --- a/build/schema.xml +++ b/build/schema.xml @@ -221,7 +221,7 @@ - + diff --git a/build/sql/schema.sql b/build/sql/schema.sql index 8e4275dc0..9376c9ac1 100644 --- a/build/sql/schema.sql +++ b/build/sql/schema.sql @@ -338,7 +338,7 @@ DROP TABLE "cc_schedule" CASCADE; CREATE TABLE "cc_schedule" ( - "id" INT8 NOT NULL, + "id" serial NOT NULL, "playlist_id" INTEGER NOT NULL, "starts" TIMESTAMP NOT NULL, "ends" TIMESTAMP NOT NULL,