CC-4223: Smart playlists: BPM criteria should have numeric modifiers

-done
This commit is contained in:
denise 2012-08-15 16:40:04 -04:00
parent 1dbdadef62
commit ea621fd9dc
7 changed files with 31 additions and 22 deletions

View file

@ -189,7 +189,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
/**
* The value for the bpm field.
* @var string
* @var int
*/
protected $bpm;
@ -814,7 +814,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
/**
* Get the [bpm] column value.
*
* @return string
* @return int
*/
public function getDbBpm()
{
@ -1822,13 +1822,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
/**
* Set the value of [bpm] column.
*
* @param string $v new value
* @param int $v new value
* @return CcFiles The current object (for fluent API support)
*/
public function setDbBpm($v)
{
if ($v !== null) {
$v = (string) $v;
$v = (int) $v;
}
if ($this->bpm !== $v) {
@ -2678,7 +2678,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
$this->track_number = ($row[$startcol + 23] !== null) ? (int) $row[$startcol + 23] : null;
$this->channels = ($row[$startcol + 24] !== null) ? (int) $row[$startcol + 24] : null;
$this->url = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null;
$this->bpm = ($row[$startcol + 26] !== null) ? (string) $row[$startcol + 26] : null;
$this->bpm = ($row[$startcol + 26] !== null) ? (int) $row[$startcol + 26] : null;
$this->rating = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null;
$this->encoded_by = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null;
$this->disc_number = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null;

View file

@ -191,7 +191,7 @@
* @method CcFiles findOneByDbTrackNumber(int $track_number) Return the first CcFiles filtered by the track_number column
* @method CcFiles findOneByDbChannels(int $channels) Return the first CcFiles filtered by the channels column
* @method CcFiles findOneByDbUrl(string $url) Return the first CcFiles filtered by the url column
* @method CcFiles findOneByDbBpm(string $bpm) Return the first CcFiles filtered by the bpm column
* @method CcFiles findOneByDbBpm(int $bpm) Return the first CcFiles filtered by the bpm column
* @method CcFiles findOneByDbRating(string $rating) Return the first CcFiles filtered by the rating column
* @method CcFiles findOneByDbEncodedBy(string $encoded_by) Return the first CcFiles filtered by the encoded_by column
* @method CcFiles findOneByDbDiscNumber(string $disc_number) Return the first CcFiles filtered by the disc_number column
@ -255,7 +255,7 @@
* @method array findByDbTrackNumber(int $track_number) Return CcFiles objects filtered by the track_number column
* @method array findByDbChannels(int $channels) Return CcFiles objects filtered by the channels column
* @method array findByDbUrl(string $url) Return CcFiles objects filtered by the url column
* @method array findByDbBpm(string $bpm) Return CcFiles objects filtered by the bpm column
* @method array findByDbBpm(int $bpm) Return CcFiles objects filtered by the bpm column
* @method array findByDbRating(string $rating) Return CcFiles objects filtered by the rating column
* @method array findByDbEncodedBy(string $encoded_by) Return CcFiles objects filtered by the encoded_by column
* @method array findByDbDiscNumber(string $disc_number) Return CcFiles objects filtered by the disc_number column
@ -1061,20 +1061,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria
/**
* Filter the query on the bpm column
*
* @param string $dbBpm The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param int|array $dbBpm 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 filterByDbBpm($dbBpm = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbBpm)) {
if (is_array($dbBpm)) {
$useMinMax = false;
if (isset($dbBpm['min'])) {
$this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbBpm['max'])) {
$this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbBpm)) {
$dbBpm = str_replace('*', '%', $dbBpm);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm, $comparison);