diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index f9cee1be5..b55848a21 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -592,7 +592,7 @@ class Application_Model_StoredFile { $fileSelect[] = $key; } //need to cast certain data as ints for the union to search on. - else if (in_array($key, array("track_number"))){ + else if (in_array($key, array("track_number", "bit_rate", "sample_rate"))){ $plSelect[] = "NULL::int AS ".$key; $fileSelect[] = $key; } diff --git a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php index 7426b39e4..38935a31d 100644 --- a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php @@ -54,8 +54,8 @@ class CcFilesTableMap extends TableMap { $this->addColumn('MD5', 'DbMd5', 'CHAR', false, 32, null); $this->addColumn('TRACK_TITLE', 'DbTrackTitle', 'VARCHAR', false, 512, null); $this->addColumn('ARTIST_NAME', 'DbArtistName', 'VARCHAR', false, 512, null); - $this->addColumn('BIT_RATE', 'DbBitRate', 'VARCHAR', false, 32, null); - $this->addColumn('SAMPLE_RATE', 'DbSampleRate', 'VARCHAR', false, 32, null); + $this->addColumn('BIT_RATE', 'DbBitRate', 'INTEGER', false, null, null); + $this->addColumn('SAMPLE_RATE', 'DbSampleRate', 'INTEGER', false, null, null); $this->addColumn('FORMAT', 'DbFormat', 'VARCHAR', false, 128, null); $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00'); $this->addColumn('ALBUM_TITLE', 'DbAlbumTitle', 'VARCHAR', false, 512, null); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php index 6bdbd6b3d..2c4a2148f 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php @@ -128,13 +128,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * The value for the bit_rate field. - * @var string + * @var int */ protected $bit_rate; /** * The value for the sample_rate field. - * @var string + * @var int */ protected $sample_rate; @@ -703,7 +703,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * Get the [bit_rate] column value. * - * @return string + * @return int */ public function getDbBitRate() { @@ -713,7 +713,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * Get the [sample_rate] column value. * - * @return string + * @return int */ public function getDbSampleRate() { @@ -1578,13 +1578,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * Set the value of [bit_rate] column. * - * @param string $v new value + * @param int $v new value * @return CcFiles The current object (for fluent API support) */ public function setDbBitRate($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } if ($this->bit_rate !== $v) { @@ -1598,13 +1598,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * Set the value of [sample_rate] column. * - * @param string $v new value + * @param int $v new value * @return CcFiles The current object (for fluent API support) */ public function setDbSampleRate($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } if ($this->sample_rate !== $v) { @@ -2575,8 +2575,8 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->md5 = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; $this->track_title = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; $this->artist_name = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; - $this->bit_rate = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; - $this->sample_rate = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; + $this->bit_rate = ($row[$startcol + 16] !== null) ? (int) $row[$startcol + 16] : null; + $this->sample_rate = ($row[$startcol + 17] !== null) ? (int) $row[$startcol + 17] : null; $this->format = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null; $this->length = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; $this->album_title = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 4921e9eb8..79bc29857 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -175,8 +175,8 @@ * @method CcFiles findOneByDbMd5(string $md5) Return the first CcFiles filtered by the md5 column * @method CcFiles findOneByDbTrackTitle(string $track_title) Return the first CcFiles filtered by the track_title column * @method CcFiles findOneByDbArtistName(string $artist_name) Return the first CcFiles filtered by the artist_name column - * @method CcFiles findOneByDbBitRate(string $bit_rate) Return the first CcFiles filtered by the bit_rate column - * @method CcFiles findOneByDbSampleRate(string $sample_rate) Return the first CcFiles filtered by the sample_rate column + * @method CcFiles findOneByDbBitRate(int $bit_rate) Return the first CcFiles filtered by the bit_rate column + * @method CcFiles findOneByDbSampleRate(int $sample_rate) Return the first CcFiles filtered by the sample_rate column * @method CcFiles findOneByDbFormat(string $format) Return the first CcFiles filtered by the format column * @method CcFiles findOneByDbLength(string $length) Return the first CcFiles filtered by the length column * @method CcFiles findOneByDbAlbumTitle(string $album_title) Return the first CcFiles filtered by the album_title column @@ -238,8 +238,8 @@ * @method array findByDbMd5(string $md5) Return CcFiles objects filtered by the md5 column * @method array findByDbTrackTitle(string $track_title) Return CcFiles objects filtered by the track_title column * @method array findByDbArtistName(string $artist_name) Return CcFiles objects filtered by the artist_name column - * @method array findByDbBitRate(string $bit_rate) Return CcFiles objects filtered by the bit_rate column - * @method array findByDbSampleRate(string $sample_rate) Return CcFiles objects filtered by the sample_rate column + * @method array findByDbBitRate(int $bit_rate) Return CcFiles objects filtered by the bit_rate column + * @method array findByDbSampleRate(int $sample_rate) Return CcFiles objects filtered by the sample_rate column * @method array findByDbFormat(string $format) Return CcFiles objects filtered by the format column * @method array findByDbLength(string $length) Return CcFiles objects filtered by the length column * @method array findByDbAlbumTitle(string $album_title) Return CcFiles objects filtered by the album_title column @@ -797,20 +797,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria /** * Filter the query on the bit_rate column * - * @param string $dbBitRate The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param int|array $dbBitRate 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 CcFilesQuery The current query, for fluid interface */ public function filterByDbBitRate($dbBitRate = null, $comparison = null) { - if (null === $comparison) { - if (is_array($dbBitRate)) { + if (is_array($dbBitRate)) { + $useMinMax = false; + if (isset($dbBitRate['min'])) { + $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBitRate['max'])) { + $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbBitRate)) { - $dbBitRate = str_replace('*', '%', $dbBitRate); - $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate, $comparison); @@ -819,20 +828,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria /** * Filter the query on the sample_rate column * - * @param string $dbSampleRate The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param int|array $dbSampleRate 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 CcFilesQuery The current query, for fluid interface */ public function filterByDbSampleRate($dbSampleRate = null, $comparison = null) { - if (null === $comparison) { - if (is_array($dbSampleRate)) { + if (is_array($dbSampleRate)) { + $useMinMax = false; + if (isset($dbSampleRate['min'])) { + $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSampleRate['max'])) { + $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbSampleRate)) { - $dbSampleRate = str_replace('*', '%', $dbSampleRate); - $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate, $comparison); diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index 9c726d804..85aca369f 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -51,8 +51,8 @@ - - + + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 794a4aee9..455ccbf5c 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -77,8 +77,8 @@ CREATE TABLE "cc_files" "md5" CHAR(32), "track_title" VARCHAR(512), "artist_name" VARCHAR(512), - "bit_rate" VARCHAR(32), - "sample_rate" VARCHAR(32), + "bit_rate" INTEGER, + "sample_rate" INTEGER, "format" VARCHAR(128), "length" interval default '00:00:00', "album_title" VARCHAR(512),