diff --git a/airtime_mvc/application/configs/classmap-airtime-conf.php b/airtime_mvc/application/configs/classmap-airtime-conf.php
index 692e0c3e4..7f7fcfc47 100644
--- a/airtime_mvc/application/configs/classmap-airtime-conf.php
+++ b/airtime_mvc/application/configs/classmap-airtime-conf.php
@@ -78,6 +78,13 @@ return array (
'BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php',
'BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php',
'BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php',
+ 'CcPlaylistcriteriaTableMap' => 'airtime/map/CcPlaylistcriteriaTableMap.php',
+ 'CcPlaylistcriteriaPeer' => 'airtime/CcPlaylistcriteriaPeer.php',
+ 'CcPlaylistcriteria' => 'airtime/CcPlaylistcriteria.php',
+ 'CcPlaylistcriteriaQuery' => 'airtime/CcPlaylistcriteriaQuery.php',
+ 'BaseCcPlaylistcriteriaPeer' => 'airtime/om/BaseCcPlaylistcriteriaPeer.php',
+ 'BaseCcPlaylistcriteria' => 'airtime/om/BaseCcPlaylistcriteria.php',
+ 'BaseCcPlaylistcriteriaQuery' => 'airtime/om/BaseCcPlaylistcriteriaQuery.php',
'CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php',
'CcPrefPeer' => 'airtime/CcPrefPeer.php',
'CcPref' => 'airtime/CcPref.php',
diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index 237bbb570..032d62ba3 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -22,6 +22,9 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('set-playlist-description', 'json')
->addActionContext('playlist-preview', 'json')
->addActionContext('get-playlist', 'json')
+ ->addActionContext('smart-playlist-criteria-save', 'json')
+ ->addActionContext('smart-playlist-generate', 'json')
+ ->addActionContext('smart-playlist-shuffle', 'json')
->initContext();
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
@@ -67,18 +70,32 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->pl);
}
- private function createFullResponse($pl = null)
+ private function createFullResponse($pl = null, $isJson = false)
{
if (isset($pl)) {
$formatter = new LengthFormatter($pl->getLength());
$this->view->length = $formatter->format();
+
+ $form = new Application_Form_SmartPlaylistCriteria();
+ $form->removeDecorator('DtDdWrapper');
+ $form->startForm($pl->getId());
+ $this->view->form = $form;
$this->view->pl = $pl;
$this->view->id = $pl->getId();
- $this->view->html = $this->view->render('playlist/playlist.phtml');
+ if ($isJson){
+ return $this->view->render('playlist/playlist.phtml');
+ }else{
+ $this->view->html = $this->view->render('playlist/playlist.phtml');
+ }
unset($this->view->pl);
- } else {
- $this->view->html = $this->view->render('playlist/playlist.phtml');
+ }
+ else {
+ if ($isJson){
+ return $this->view->render('playlist/playlist.phtml');
+ }else{
+ $this->view->html = $this->view->render('playlist/playlist.phtml');
+ }
}
}
@@ -87,6 +104,12 @@ class PlaylistController extends Zend_Controller_Action
$this->view->error = $e->getMessage();
}
+ private function playlistDynamic($pl)
+ {
+ $this->view->error = "You cannot add tracks to dynamic playlist.";
+ $this->createFullResponse($pl);
+ }
+
private function playlistNotFound()
{
$this->view->error = "Playlist not found";
@@ -136,6 +159,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_playlistbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
try {
@@ -147,6 +171,9 @@ class PlaylistController extends Zend_Controller_Action
if($isAdminOrPM || $pl->getCreatorId() == $userInfo->id){
$this->view->pl = $pl;
+ $form = new Application_Form_SmartPlaylistCriteria();
+ $form->startForm($this->pl_sess->id);
+ $this->view->form = $form;
}
$formatter = new LengthFormatter($pl->getLength());
@@ -176,6 +203,8 @@ class PlaylistController extends Zend_Controller_Action
{
$id = $this->_getParam('id', null);
Logging::log("editing playlist {$id}");
+ //$form = new Application_Form_SmartPlaylistCriteria();
+
if (!is_null($id)) {
$this->changePlaylist($id);
@@ -230,16 +259,26 @@ class PlaylistController extends Zend_Controller_Action
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
-
+
try {
$pl = $this->getPlaylist();
- $pl->addAudioClips($ids, $afterItem, $addType);
- $this->createUpdateResponse($pl);
- } catch (PlaylistOutDatedException $e) {
- $this->playlistOutdated($e);
- } catch (PlaylistNotFoundException $e) {
+ if ($pl->isStatic()) {
+ $pl->addAudioClips($ids, $afterItem, $addType);
+ $this->createUpdateResponse($pl);
+ } else {
+ throw new PlaylistDyanmicException;
+ }
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
+ catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
- } catch (Exception $e) {
+ }
+ catch (PlaylistDyanmicException $e) {
+ $this->playlistDynamic($pl);
+ }
+ catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
@@ -409,4 +448,55 @@ class PlaylistController extends Zend_Controller_Action
$this->playlistUnknownError($e);
}
}
+
+ public function smartPlaylistCriteriaSaveAction()
+ {
+ $request = $this->getRequest();
+ $params = $request->getPost();
+ $pl = new Application_Model_Playlist($params['pl_id']);
+ $result = $pl->saveSmartPlaylistCriteria($params['data']);
+ die(json_encode($result));
+ }
+
+ public function smartPlaylistGenerateAction()
+ {
+ $request = $this->getRequest();
+ $params = $request->getPost();
+ $pl = new Application_Model_Playlist($params['pl_id']);
+ $result = $pl->generateSmartPlaylist($params['data']);
+ if ($result['result'] == 0) {
+ try {
+ die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true))));
+ }
+ catch (PlaylistNotFoundException $e) {
+ $this->playlistNotFound();
+ }
+ catch (Exception $e) {
+ $this->playlistUnknownError($e);
+ }
+ }else{
+ die(json_encode($result));
+ }
+ }
+
+ public function smartPlaylistShuffleAction()
+ {
+ $request = $this->getRequest();
+ $params = $request->getPost();
+ $pl = new Application_Model_Playlist($params['pl_id']);
+ $result = $pl->shuffleSmartPlaylist();
+ if ($result['result'] == 0) {
+ try {
+ die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true))));
+ }
+ catch (PlaylistNotFoundException $e) {
+ $this->playlistNotFound();
+ }
+ catch (Exception $e) {
+ $this->playlistUnknownError($e);
+ }
+ }else{
+ die(json_encode($result));
+ }
+ }
}
diff --git a/airtime_mvc/application/forms/SmartPlaylistCriteria.php b/airtime_mvc/application/forms/SmartPlaylistCriteria.php
new file mode 100644
index 000000000..a12328de9
--- /dev/null
+++ b/airtime_mvc/application/forms/SmartPlaylistCriteria.php
@@ -0,0 +1,240 @@
+ "Select criteria",
+ "album_title" => "Album",
+ "artist_name" => "Artist",
+ "bit_rate" => "Bit Rate",
+ "bpm" => "Bpm",
+ "comments" => "Comments",
+ "composer" => "Composer",
+ "conductor" => "Conductor",
+ "disc_number" => "Disc Number",
+ "genre" => "Genre",
+ "isrc_number" => "ISRC",
+ "label" => "Label",
+ "language" => "Language",
+ "mtime" => "Last Modified",
+ "length" => "Length",
+ "lyricist" => "Lyricist",
+ "mood" => "Mood",
+ "name" => "Name",
+ "orchestra" => "Orchestra",
+ "radio_station_name" => "Radio Station Name",
+ "rating" => "Rating",
+ "sample_rate" => "Sample Rate",
+ "soundcloud_id" => "Soundcloud Upload",
+ "track_title" => "Title",
+ "track_num" => "Track Number",
+ "utime" => "Uploaded",
+ "year" => "Year"
+ );
+
+ $criteriaTypes = array(
+ 0 => "",
+ "album_title" => "s",
+ "artist_name" => "s",
+ "bit_rate" => "n",
+ "bpm" => "n",
+ "comments" => "s",
+ "composer" => "s",
+ "conductor" => "s",
+ "utime" => "n",
+ "mtime" => "n",
+ "disc_number" => "n",
+ "genre" => "s",
+ "isrc_number" => "s",
+ "label" => "s",
+ "language" => "s",
+ "length" => "n",
+ "lyricist" => "s",
+ "mood" => "s",
+ "name" => "s",
+ "orchestra" => "s",
+ "radio_station_name" => "s",
+ "rating" => "n",
+ "sample_rate" => "n",
+ "soundcloud_id" => "n",
+ "track_title" => "s",
+ "track_num" => "n",
+ "year" => "n"
+ );
+
+ $stringCriteriaOptions = array(
+ "0" => "Select modifier",
+ "contains" => "contains",
+ "does not contain" => "does not contain",
+ "is" => "is",
+ "is not" => "is not",
+ "starts with" => "starts with",
+ "ends with" => "ends with"
+ );
+
+ $numericCriteriaOptions = array(
+ "0" => "Select modifier",
+ "is" => "is",
+ "is not" => "is not",
+ "is greater than" => "is greater than",
+ "is less than" => "is less than",
+ "is in the range" => "is in the range"
+ );
+
+ $limitOptions = array(
+ "hours" => "hours",
+ "minutes" => "minutes",
+ "items" => "items"
+ );
+
+ // load type
+ $out = CcPlaylistQuery::create()->findPk($p_playlistId);
+ if ($out->getDbType() == "static") {
+ $playlistType = 0;
+ } else {
+ $playlistType = 1;
+ }
+
+ $spType = new Zend_Form_Element_Radio('sp_type');
+ $spType->setLabel('Set smart playlist type:')
+ ->setDecorators(array('viewHelper'))
+ ->setMultiOptions(array(
+ 'static' => 'Static',
+ 'dynamic' => 'Dynamic'
+ ))
+ ->setValue($playlistType);
+ $this->addElement($spType);
+
+ // load criteria from db
+ $out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
+
+ $storedCrit = array();
+ foreach ($out as $crit) {
+ $criteria = $crit->getDbCriteria();
+ $modifier = $crit->getDbModifier();
+ $value = $crit->getDbValue();
+ $extra = $crit->getDbExtra();
+
+ if($criteria == "limit"){
+ $storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
+ }else{
+ $storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
+ }
+ }
+
+ $openSmartPlaylistOption = false;
+ if (!empty($storedCrit)) {
+ $openSmartPlaylistOption = true;
+ }
+
+ $numElements = count($criteriaOptions);
+ for ($i = 0; $i < $numElements; $i++) {
+ $criteriaType = "";
+ $criteria = new Zend_Form_Element_Select('sp_criteria_field_'.$i);
+ $criteria->setAttrib('class', 'input_select sp_input_select')
+ ->setValue('Select criteria')
+ ->setDecorators(array('viewHelper'))
+ ->setMultiOptions($criteriaOptions);
+ if ($i != 0 && !isset($storedCrit["crit"][$i])){
+ $criteria->setAttrib('disabled', 'disabled');
+ }
+ if (isset($storedCrit["crit"][$i])) {
+ $criteriaType = $criteriaTypes[$storedCrit["crit"][$i]["criteria"]];
+ $criteria->setValue($storedCrit["crit"][$i]["criteria"]);
+ }
+ $this->addElement($criteria);
+
+ $criteriaModifers = new Zend_Form_Element_Select('sp_criteria_modifier_'.$i);
+ $criteriaModifers->setValue('Select modifier')
+ ->setAttrib('class', 'input_select sp_input_select')
+ ->setDecorators(array('viewHelper'));
+ if ($i != 0 && !isset($storedCrit["crit"][$i])){
+ $criteriaModifers->setAttrib('disabled', 'disabled');
+ }
+ if (isset($storedCrit["crit"][$i])) {
+ if($criteriaType == "s"){
+ $criteriaModifers->setMultiOptions($stringCriteriaOptions);
+ }else{
+ $criteriaModifers->setMultiOptions($numericCriteriaOptions);
+ }
+ $criteriaModifers->setValue($storedCrit["crit"][$i]["modifier"]);
+ }else{
+ $criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
+ }
+ $this->addElement($criteriaModifers);
+
+ $criteriaValue = new Zend_Form_Element_Text('sp_criteria_value_'.$i);
+ $criteriaValue->setAttrib('class', 'input_text sp_input_text')
+ ->setDecorators(array('viewHelper'));
+ if ($i != 0 && !isset($storedCrit["crit"][$i])){
+ $criteriaValue->setAttrib('disabled', 'disabled');
+ }
+ if (isset($storedCrit["crit"][$i])) {
+ $criteriaValue->setValue($storedCrit["crit"][$i]["value"]);
+ }
+ $this->addElement($criteriaValue);
+
+ $criteriaExtra = new Zend_Form_Element_Text('sp_criteria_extra_'.$i);
+ $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
+ ->setDecorators(array('viewHelper'));
+ if (isset($storedCrit["crit"][$i]["extra"])) {
+ $criteriaExtra->setValue($storedCrit["crit"][$i]["extra"]);
+ $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
+ }else{
+ $criteriaExtra->setAttrib('disabled', 'disabled');
+ }
+ $this->addElement($criteriaExtra);
+ }
+
+ $limit = new Zend_Form_Element_Select('sp_limit_options');
+ $limit->setAttrib('class', 'sp_input_select');
+ $limit->setDecorators(array('viewHelper'));
+ $limit->setMultiOptions($limitOptions);
+ if (isset($storedCrit["limit"])) {
+ $limit->setValue($storedCrit["limit"]["modifier"]);
+ }
+ $this->addElement($limit);
+
+ $limitValue = new Zend_Form_Element_Text('sp_limit_value');
+ $limitValue->setAttrib('class', 'sp_input_text_limit');
+ $limitValue->setLabel('Limit to');
+ $limitValue->setDecorators(array('viewHelper'));
+ $this->addElement($limitValue);
+ if (isset($storedCrit["limit"])) {
+ $limitValue->setValue($storedCrit["limit"]["value"]);
+ }
+
+ $save = new Zend_Form_Element_Button('save_button');
+ $save->setAttrib('class', 'ui-button ui-state-default sp-button');
+ $save->setAttrib('title', 'Save criteria only');
+ $save->setIgnore(true);
+ $save->setLabel('Save');
+ $save->setDecorators(array('viewHelper'));
+ $this->addElement($save);
+
+ $generate = new Zend_Form_Element_Button('generate_button');
+ $generate->setAttrib('class', 'ui-button ui-state-default sp-button');
+ $generate->setAttrib('title', 'Save criteria and generate playlist content');
+ $generate->setIgnore(true);
+ $generate->setLabel('Generate');
+ $generate->setDecorators(array('viewHelper'));
+ $this->addElement($generate);
+
+ $shuffle = new Zend_Form_Element_Button('shuffle_button');
+ $shuffle->setAttrib('class', 'ui-button ui-state-default sp-button');
+ $shuffle->setAttrib('title', 'Shuffle playlist content');
+ $shuffle->setIgnore(true);
+ $shuffle->setLabel('Shuffle');
+ $shuffle->setDecorators(array('viewHelper'));
+ $this->addElement($shuffle);
+
+ $this->setDecorators(array(
+ array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', "openOption"=> $openSmartPlaylistOption,
+ 'criteriasLength' => count($criteriaOptions)))
+ ));
+ }
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php
index f02c13f5e..d499d6a24 100644
--- a/airtime_mvc/application/models/Playlist.php
+++ b/airtime_mvc/application/models/Playlist.php
@@ -45,6 +45,47 @@ class Application_Model_Playlist
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
+
+ private static $modifier2CriteriaMap = array(
+ "contains" => Criteria::LIKE,
+ "does not contain" => Criteria::NOT_LIKE,
+ "is" => Criteria::EQUAL,
+ "is not" => Criteria::NOT_EQUAL,
+ "starts with" => Criteria::LIKE,
+ "ends with" => Criteria::LIKE,
+ "is greater than" => Criteria::GREATER_THAN,
+ "is less than" => Criteria::LESS_THAN,
+ "is in the range" => Criteria::CUSTOM);
+
+ private static $criteria2PeerMap = array(
+ 0 => "Select criteria",
+ "album_title" => "DbAlbumTitle",
+ "artist_name" => "DbArtistName",
+ "bit_rate" => "DbBitRate",
+ "bpm" => "DbBpm",
+ "comments" => "DbComments",
+ "composer" => "DbComposer",
+ "conductor" => "DbConductor",
+ "utime" => "DbUtime",
+ "mtime" => "DbMtime",
+ "disc_number" => "DbDiscNumber",
+ "genre" => "DbGenre",
+ "isrc_number" => "DbIsrcNumber",
+ "label" => "DbLabel",
+ "language" => "DbLanguage",
+ "length" => "DbLength",
+ "lyricist" => "DbLyricist",
+ "mood" => "DbMood",
+ "name" => "DbName",
+ "orchestra" => "DbOrchestra",
+ "radio_station_name" => "DbRadioStation",
+ "rating" => "DbRating",
+ "sample_rate" => "DbSampleRate",
+ "soundcloud_id" => "DbSoundcloudId",
+ "track_title" => "DbTrackTitle",
+ "track_num" => "DbTrackNum",
+ "year" => "DbYear"
+ );
public function __construct($id=null, $con=null)
@@ -251,6 +292,14 @@ class Application_Model_Playlist
throw new Exception("trying to add a file that does not exist.");
}
}
+
+ public function isStatic(){
+ if ($this->pl->getDbType() == "static") {
+ return true;
+ } else {
+ return false;
+ }
+ }
/*
* @param array $p_items
@@ -825,9 +874,263 @@ class Application_Model_Playlist
$leftOvers = array_diff($selectedPls, $ownedPls);
return $leftOvers;
}
+
+ /**
+ * Delete all files from playlist
+ * @param int $p_playlistId
+ */
+ public function deleteAllFilesFromPlaylist()
+ {
+ CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
+ }
+
+
+ // smart playlist functions start
+ public function shuffleSmartPlaylist(){
+ // if it here that means it's static pl
+ $this->saveType("static");
+ $contents = CcPlaylistcontentsQuery::create()
+ ->filterByDbPlaylistId($this->id)
+ ->orderByDbPosition()
+ ->find();
+ $shuffledPos = range(0, count($contents)-1);
+ shuffle($shuffledPos);
+ $temp = new CcPlaylist();
+ foreach ($contents as $item) {
+ $item->setDbPosition(array_shift($shuffledPos));
+ $item->save();
+ }
+ return array("result"=>0);
+ }
+
+ public function saveType($p_playlistType)
+ {
+ // saving dynamic/static flag
+ CcPlaylistQuery::create()->findPk($this->id)->setDbType($p_playlistType)->save();
+ }
+
+ /**
+ * Saves smart playlist criteria
+ * @param array $p_criteria
+ */
+ public function saveSmartPlaylistCriteria($p_criteria)
+ {
+ $data = $this->organizeSmartPlyalistCriteria($p_criteria);
+ // things we need to check
+ // 1. limit value shouldn't be empty and has upperbound of 24 hrs
+ // 2. sp_criteria or sp_criteria_modifier shouldn't be 0
+ // 3. validate formate according to DB column type
+ $multiplier = 1;
+ $result = 0;
+ $errors = array();
+ $error = array();
+
+ // saving dynamic/static flag
+ $playlistType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic';
+ $this->saveType($playlistType);
+
+ if ($data['etc']['sp_limit_options'] == 'hours') {
+ $multiplier = 60;
+ }
+ if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
+ if ( $data['etc']['sp_limit_value'] == "" || intval($data['etc']['sp_limit_value']) == 0) {
+ $error[] = "Limit cannot be empty or 0";
+ } else {
+ $mins = $data['etc']['sp_limit_value'] * $multiplier;
+ if ($mins > 14400) {
+ $error[] = "Limit cannot be more than 24 hrs";
+ }
+ }
+ if (count($error) > 0){
+ $errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
+ }
+ }
+
+ // format validation
+ foreach ($data['criteria'] as $key=>$d){
+ $error = array();
+ // check for not selected select box
+ if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
+ $error[] = "You must select Criteria and Modifier";
+ } else {
+ // we need to take care 'length' specially since the column type is varchar
+ if ($d['sp_criteria_field'] == 'length') {
+ if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
+ $error[] = "'Length' should be in '00:00:00' format";
+ }
+ }else{
+ if (CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']])->getType() == PropelColumnTypes::TIMESTAMP) {
+ if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
+ $error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
+ }
+ }
+ }
+ }
+
+ if ($d['sp_criteria_value'] == "") {
+ $error[] = "Value cannot be empty";
+ }
+ if(count($error) > 0){
+ $errors[] = array("element"=>"sp_criteria_field_".$key, "msg"=>$error);
+ }
+ }
+ $result = count($errors) > 0 ? 1 :0;
+ if ($result == 0) {
+ $this->storeCriteriaIntoDb($data);
+ }
+ return array("result"=>$result, "errors"=>$errors);
+ }
+
+ public function storeCriteriaIntoDb($p_criteriaData){
+ // delete criteria under $p_playlistId
+ CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($this->id)->delete();
+
+ foreach( $p_criteriaData['criteria'] as $d){
+ $qry = new CcPlaylistcriteria();
+ $qry->setDbCriteria($d['sp_criteria_field'])
+ ->setDbModifier($d['sp_criteria_modifier'])
+ ->setDbValue($d['sp_criteria_value'])
+ ->setDbPlaylistId($this->id);
+
+ if (isset($d['sp_criteria_extra'])) {
+ $qry->setDbExtra($d['sp_criteria_extra']);
+ }
+ $qry->save();
+ }
+
+ // insert limit info
+ $qry = new CcPlaylistcriteria();
+ $qry->setDbCriteria("limit")
+ ->setDbModifier($p_criteriaData['etc']['sp_limit_options'])
+ ->setDbValue($p_criteriaData['etc']['sp_limit_value'])
+ ->setDbPlaylistId($this->id)
+ ->save();
+ }
+
+ /**
+ * generate list of tracks. This function saves creiteria and generate
+ * tracks.
+ * @param array $p_criteria
+ */
+ public function generateSmartPlaylist($p_criteria, $returnList=false)
+ {
+ $result = $this->saveSmartPlaylistCriteria($p_criteria);
+ if ($result['result'] != 0) {
+ return $result;
+ } else {
+ $insertList = $this->getListOfFilesUnderLimit();
+ $this->deleteAllFilesFromPlaylist();
+ $this->addAudioClips(array_keys($insertList));
+ return array("result"=>0);
+ }
+ }
+
+ public function getListOfFilesUnderLimit()
+ {
+ $info = $this->getListofFilesMeetCriteria();
+ $files = $info['files'];
+ $limit = $info['limit'];
+ // construct ids of track candidates
+ $insertList = array();
+ $totalTime = 0;
+ while ($totalTime < $limit['time'] && !empty($files)) {
+ $key = array_rand($files);
+ $insertList[$key] = $files[$key];
+ $totalTime += $files[$key];
+ unset($files[$key]);
+ if ( !is_null($limit['items']) && $limit['items'] == count($insertList)) {
+ break;
+ }
+ }
+ return $insertList;
+ }
+
+ // this function return list of propel object
+ private function getListofFilesMeetCriteria()
+ {
+ $out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($this->id);
+ $storedCrit = array();
+ foreach ($out as $crit) {
+ $criteria = $crit->getDbCriteria();
+ $modifier = $crit->getDbModifier();
+ $value = $crit->getDbValue();
+ $extra = $crit->getDbExtra();
+
+ if($criteria == "limit"){
+ $storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
+ }else{
+ $storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
+ }
+ }
+ $qry = CcFilesQuery::create();
+ foreach ($storedCrit["crit"] as $criteria) {
+ // propel doc says we should use phpname for column name but
+ // it looks like we have to use actual column name
+ //$spCriteria = self::$criteria2PeerMap[$criteria['criteria']];
+ $spCriteria = $criteria['criteria'];
+ $spCriteriaModifier = $criteria['modifier'];
+ $spCriteriaValue = $criteria['value'];
+ if ($spCriteriaModifier == "starts with") {
+ $spCriteriaValue = "$spCriteriaValue%";
+ } else if ($spCriteriaModifier == "ends with") {
+ $spCriteriaValue = "%$spCriteriaValue";
+ } else if ($spCriteriaModifier == "is in the range") {
+ $spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria < '$criteria[extra]'";
+ }
+ $spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
+ try{
+ $qry->filterBy($spCriteria, $spCriteriaValue, $spCriteriaModifier);
+ }catch (Exception $e){
+ Logging::log($e);
+ }
+ }
+ // construct limit restriction
+ $limits = array();
+ if ($storedCrit['limit']['modifier'] == "items") {
+ $limits['time'] = 1440 * 60;
+ $limits['items'] = $storedCrit['limit']['value'];
+ } else {
+ $limits['time'] = $storedCrit['limit']['modifier'] == "hours" ? intval($storedCrit['limit']['value']) * 60 * 60 : intval($storedCrit['limit']['value'] * 60);
+ $limits['items'] = null;
+ }
+ Logging::log("2222");
+ try{
+ $out = $qry->find();
+ Logging::log("3333");
+ $files = array();
+ foreach ($out as $file) {
+ $files[$file->getDbId()] = Application_Common_DateHelper::calculateLengthInSeconds($file->getDbLength());
+ }
+ Logging::log($files);
+ return array("files"=>$files, "limit"=>$limits);
+ }catch(Exception $e){
+ Logging::log($e);
+ }
+
+ }
+
+ private static function organizeSmartPlyalistCriteria($p_criteria)
+ {
+ $fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra');
+ $output = array();
+ foreach ($p_criteria as $ele) {
+ $index = strrpos($ele['name'], '_');
+ $fieldName = substr($ele['name'], 0, $index);
+ if (in_array($fieldName, $fieldNames)) {
+ $rowNum = intval(substr($ele['name'], $index+1));
+ $output['criteria'][$rowNum][$fieldName] = trim($ele['value']);
+ }else{
+ $output['etc'][$ele['name']] = $ele['value'];
+ }
+ }
+
+ return $output;
+ }
+ // smart playlist functions end
} // class Playlist
class PlaylistNotFoundException extends Exception {}
class PlaylistNoPermissionException extends Exception {}
class PlaylistOutDatedException extends Exception {}
+class PlaylistDyanmicException extends Exception {}
diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php
index 692d2ad44..38197870f 100644
--- a/airtime_mvc/application/models/Scheduler.php
+++ b/airtime_mvc/application/models/Scheduler.php
@@ -145,32 +145,50 @@ class Application_Model_Scheduler
$files[] = $data;
}
- } elseif ($type === "playlist") {
-
- $contents = CcPlaylistcontentsQuery::create()
- ->orderByDbPosition()
- ->filterByDbPlaylistId($id)
- ->find($this->con);
+ }
+ else if ($type === "playlist") {
+
+ // find if the playslit is static or dynamic
+ $c = new Criteria();
+ $c->add(CcPlaylistPeer::ID, $id);
+ $pl = CcPlaylistPeer::doSelect($c);
+ $playlistType = $pl[0]->getDbType();
+
+ if ($playlistType == "static") {
+ $contents = CcPlaylistcontentsQuery::create()
+ ->orderByDbPosition()
+ ->filterByDbPlaylistId($id)
+ ->find($this->con);
+ } else {
+ $pl = new Application_Model_Playlist($id);
+ $contents = $pl->getListOfFilesUnderLimit();
+ }
if (is_null($contents)) {
throw new Exception("A selected Playlist does not exist!");
}
- foreach ($contents as $plItem) {
-
- $file = $plItem->getCcFiles($this->con);
- if (isset($file) && $file->getDbFileExists()) {
-
- $data = $this->fileInfo;
- $data["id"] = $plItem->getDbFileId();
- $data["cliplength"] = $plItem->getDbCliplength();
- $data["cuein"] = $plItem->getDbCuein();
- $data["cueout"] = $plItem->getDbCueout();
- $data["fadein"] = $plItem->getDbFadein();
- $data["fadeout"] = $plItem->getDbFadeout();
-
- $files[] = $data;
+ foreach ($contents as $fileId => $plItem) {
+ $data = $this->fileInfo;
+ if ($playlistType == "static"){
+ $file = $plItem->getCcFiles($this->con);
+ if (isset($file) && $file->getDbFileExists()) {
+ $data["id"] = $plItem->getDbFileId();
+ $data["cliplength"] = $plItem->getDbCliplength();
+ $data["cuein"] = $plItem->getDbCuein();
+ $data["cueout"] = $plItem->getDbCueout();
+ $data["fadein"] = $plItem->getDbFadein();
+ $data["fadeout"] = $plItem->getDbFadeout();
+ }
+ } else {
+ // on dynamic playslsit, $fileId is id of files
+ $file = Application_Model_StoredFile::Recall($fileId)->getPropelOrm();
+ if (isset($file) && $file->getDbFileExists()) {
+ $data["id"] = $fileId;
+ $data["cliplength"] = $file->getDbLength();
+ }
}
+ $files[] = $data;
}
}
diff --git a/airtime_mvc/application/models/airtime/CcPlaylistcriteria.php b/airtime_mvc/application/models/airtime/CcPlaylistcriteria.php
new file mode 100644
index 000000000..ae4232cdb
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/CcPlaylistcriteria.php
@@ -0,0 +1,18 @@
+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');
+ $this->addColumn('TYPE', 'DbType', 'VARCHAR', false, 7, 'static');
// validators
} // initialize()
@@ -55,6 +56,7 @@ class CcPlaylistTableMap extends TableMap {
{
$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);
+ $this->addRelation('CcPlaylistcriteria', 'CcPlaylistcriteria', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()
/**
diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistcriteriaTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistcriteriaTableMap.php
new file mode 100644
index 000000000..f564c8e30
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/map/CcPlaylistcriteriaTableMap.php
@@ -0,0 +1,58 @@
+setName('cc_playlistcriteria');
+ $this->setPhpName('CcPlaylistcriteria');
+ $this->setClassname('CcPlaylistcriteria');
+ $this->setPackage('airtime');
+ $this->setUseIdGenerator(true);
+ $this->setPrimaryKeyMethodInfo('cc_playlistcriteria_id_seq');
+ // columns
+ $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
+ $this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 16, null);
+ $this->addColumn('MODIFIER', 'DbModifier', 'VARCHAR', true, 16, null);
+ $this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 32, null);
+ $this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 32, null);
+ $this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // CcPlaylistcriteriaTableMap
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
index db4e4d222..5e8e9f23a 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
@@ -68,6 +68,13 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $length;
+ /**
+ * The value for the type field.
+ * Note: this column has a database default value of: 'static'
+ * @var string
+ */
+ protected $type;
+
/**
* @var CcSubjs
*/
@@ -78,6 +85,11 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $collCcPlaylistcontentss;
+ /**
+ * @var array CcPlaylistcriteria[] Collection to store aggregation of CcPlaylistcriteria objects.
+ */
+ protected $collCcPlaylistcriterias;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -102,6 +114,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
{
$this->name = '';
$this->length = '00:00:00';
+ $this->type = 'static';
}
/**
@@ -230,6 +243,16 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->length;
}
+ /**
+ * Get the [type] column value.
+ *
+ * @return string
+ */
+ public function getDbType()
+ {
+ return $this->type;
+ }
+
/**
* Set the value of [id] column.
*
@@ -432,6 +455,26 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbLength()
+ /**
+ * Set the value of [type] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylist The current object (for fluent API support)
+ */
+ public function setDbType($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->type !== $v || $this->isNew()) {
+ $this->type = $v;
+ $this->modifiedColumns[] = CcPlaylistPeer::TYPE;
+ }
+
+ return $this;
+ } // setDbType()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -450,6 +493,10 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return false;
}
+ if ($this->type !== 'static') {
+ return false;
+ }
+
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -479,6 +526,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
$this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->resetModified();
$this->setNew(false);
@@ -487,7 +535,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 7; // 7 = 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);
@@ -555,6 +603,8 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->aCcSubjs = null;
$this->collCcPlaylistcontentss = null;
+ $this->collCcPlaylistcriterias = null;
+
} // if (deep)
}
@@ -708,6 +758,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ if ($this->collCcPlaylistcriterias !== null) {
+ foreach ($this->collCcPlaylistcriterias as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -799,6 +857,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ if ($this->collCcPlaylistcriterias !== null) {
+ foreach ($this->collCcPlaylistcriterias as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -853,6 +919,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
return $this->getDbLength();
break;
+ case 7:
+ return $this->getDbType();
+ break;
default:
return null;
break;
@@ -884,6 +953,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$keys[4] => $this->getDbCreatorId(),
$keys[5] => $this->getDbDescription(),
$keys[6] => $this->getDbLength(),
+ $keys[7] => $this->getDbType(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
@@ -941,6 +1011,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
$this->setDbLength($value);
break;
+ case 7:
+ $this->setDbType($value);
+ break;
} // switch()
}
@@ -972,6 +1045,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]);
}
/**
@@ -990,6 +1064,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
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);
+ if ($this->isColumnModified(CcPlaylistPeer::TYPE)) $criteria->add(CcPlaylistPeer::TYPE, $this->type);
return $criteria;
}
@@ -1057,6 +1132,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbDescription($this->description);
$copyObj->setDbLength($this->length);
+ $copyObj->setDbType($this->type);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1069,6 +1145,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ foreach ($this->getCcPlaylistcriterias() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCcPlaylistcriteria($relObj->copy($deepCopy));
+ }
+ }
+
} // if ($deepCopy)
@@ -1297,6 +1379,115 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->getCcPlaylistcontentss($query, $con);
}
+ /**
+ * Clears out the collCcPlaylistcriterias collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCcPlaylistcriterias()
+ */
+ public function clearCcPlaylistcriterias()
+ {
+ $this->collCcPlaylistcriterias = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Initializes the collCcPlaylistcriterias collection.
+ *
+ * By default this just sets the collCcPlaylistcriterias collection to an empty array (like clearcollCcPlaylistcriterias());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initCcPlaylistcriterias()
+ {
+ $this->collCcPlaylistcriterias = new PropelObjectCollection();
+ $this->collCcPlaylistcriterias->setModel('CcPlaylistcriteria');
+ }
+
+ /**
+ * Gets an array of CcPlaylistcriteria objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this CcPlaylist is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelCollection|array CcPlaylistcriteria[] List of CcPlaylistcriteria objects
+ * @throws PropelException
+ */
+ public function getCcPlaylistcriterias($criteria = null, PropelPDO $con = null)
+ {
+ if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
+ // return empty collection
+ $this->initCcPlaylistcriterias();
+ } else {
+ $collCcPlaylistcriterias = CcPlaylistcriteriaQuery::create(null, $criteria)
+ ->filterByCcPlaylist($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCcPlaylistcriterias;
+ }
+ $this->collCcPlaylistcriterias = $collCcPlaylistcriterias;
+ }
+ }
+ return $this->collCcPlaylistcriterias;
+ }
+
+ /**
+ * Returns the number of related CcPlaylistcriteria objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CcPlaylistcriteria objects.
+ * @throws PropelException
+ */
+ public function countCcPlaylistcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
+ return 0;
+ } else {
+ $query = CcPlaylistcriteriaQuery::create(null, $criteria);
+ if($distinct) {
+ $query->distinct();
+ }
+ return $query
+ ->filterByCcPlaylist($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCcPlaylistcriterias);
+ }
+ }
+
+ /**
+ * Method called to associate a CcPlaylistcriteria object to this object
+ * through the CcPlaylistcriteria foreign key attribute.
+ *
+ * @param CcPlaylistcriteria $l CcPlaylistcriteria
+ * @return void
+ * @throws PropelException
+ */
+ public function addCcPlaylistcriteria(CcPlaylistcriteria $l)
+ {
+ if ($this->collCcPlaylistcriterias === null) {
+ $this->initCcPlaylistcriterias();
+ }
+ if (!$this->collCcPlaylistcriterias->contains($l)) { // only add it if the **same** object is not already associated
+ $this->collCcPlaylistcriterias[]= $l;
+ $l->setCcPlaylist($this);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1309,6 +1500,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = null;
$this->description = null;
$this->length = null;
+ $this->type = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
@@ -1335,9 +1527,15 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collCcPlaylistcriterias) {
+ foreach ((array) $this->collCcPlaylistcriterias as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
$this->collCcPlaylistcontentss = null;
+ $this->collCcPlaylistcriterias = null;
$this->aCcSubjs = null;
}
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
index da3593e02..16f69e6db 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
@@ -26,7 +26,7 @@ abstract class BaseCcPlaylistPeer {
const TM_CLASS = 'CcPlaylistTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 8;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -52,6 +52,9 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the LENGTH field */
const LENGTH = 'cc_playlist.LENGTH';
+ /** the column name for the TYPE field */
+ const TYPE = 'cc_playlist.TYPE';
+
/**
* 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
@@ -68,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', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
- BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', 'DbType', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', 'dbType', ),
+ BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, self::TYPE, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', 'TYPE', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', 'type', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -83,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, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ),
- BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, 'DbType' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, 'dbType' => 7, ),
+ BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, self::TYPE => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, 'TYPE' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, 'type' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -167,6 +170,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID);
$criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION);
$criteria->addSelectColumn(CcPlaylistPeer::LENGTH);
+ $criteria->addSelectColumn(CcPlaylistPeer::TYPE);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
@@ -175,6 +179,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.LENGTH');
+ $criteria->addSelectColumn($alias . '.TYPE');
}
}
@@ -371,6 +376,9 @@ abstract class BaseCcPlaylistPeer {
// Invalidate objects in CcPlaylistcontentsPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlaylistcontentsPeer::clearInstancePool();
+ // Invalidate objects in CcPlaylistcriteriaPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CcPlaylistcriteriaPeer::clearInstancePool();
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
index 66b50e1c2..4031f9755 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
@@ -13,6 +13,7 @@
* @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 orderByDbType($order = Criteria::ASC) Order by the type column
*
* @method CcPlaylistQuery groupByDbId() Group by the id column
* @method CcPlaylistQuery groupByDbName() Group by the name column
@@ -21,6 +22,7 @@
* @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 groupByDbType() Group by the type 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
@@ -34,6 +36,10 @@
* @method CcPlaylistQuery rightJoinCcPlaylistcontents($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcontents relation
* @method CcPlaylistQuery innerJoinCcPlaylistcontents($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcontents relation
*
+ * @method CcPlaylistQuery leftJoinCcPlaylistcriteria($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcPlaylistcriteria relation
+ * @method CcPlaylistQuery rightJoinCcPlaylistcriteria($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcriteria relation
+ * @method CcPlaylistQuery innerJoinCcPlaylistcriteria($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcriteria relation
+ *
* @method CcPlaylist findOne(PropelPDO $con = null) Return the first CcPlaylist matching the query
* @method CcPlaylist findOneOrCreate(PropelPDO $con = null) Return the first CcPlaylist matching the query, or a new CcPlaylist object populated from the query conditions when no match is found
*
@@ -44,6 +50,7 @@
* @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 CcPlaylist findOneByDbType(string $type) Return the first CcPlaylist filtered by the type 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
@@ -52,6 +59,7 @@
* @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
+ * @method array findByDbType(string $type) Return CcPlaylist objects filtered by the type column
*
* @package propel.generator.airtime.om
*/
@@ -337,6 +345,28 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison);
}
+ /**
+ * Filter the query on the type column
+ *
+ * @param string $dbType 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 filterByDbType($dbType = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbType)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbType)) {
+ $dbType = str_replace('*', '%', $dbType);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistPeer::TYPE, $dbType, $comparison);
+ }
+
/**
* Filter the query by a related CcSubjs object
*
@@ -465,6 +495,70 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', 'CcPlaylistcontentsQuery');
}
+ /**
+ * Filter the query by a related CcPlaylistcriteria object
+ *
+ * @param CcPlaylistcriteria $ccPlaylistcriteria the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CcPlaylistQuery The current query, for fluid interface
+ */
+ public function filterByCcPlaylistcriteria($ccPlaylistcriteria, $comparison = null)
+ {
+ return $this
+ ->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylistcriteria->getDbPlaylistId(), $comparison);
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CcPlaylistcriteria relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcPlaylistQuery The current query, for fluid interface
+ */
+ public function joinCcPlaylistcriteria($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CcPlaylistcriteria');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CcPlaylistcriteria');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CcPlaylistcriteria relation CcPlaylistcriteria object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcPlaylistcriteriaQuery A secondary query class using the current class as primary query
+ */
+ public function useCcPlaylistcriteriaQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCcPlaylistcriteria($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcriteria', 'CcPlaylistcriteriaQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteria.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteria.php
new file mode 100644
index 000000000..6cc3e4bc1
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteria.php
@@ -0,0 +1,1001 @@
+id;
+ }
+
+ /**
+ * Get the [criteria] column value.
+ *
+ * @return string
+ */
+ public function getDbCriteria()
+ {
+ return $this->criteria;
+ }
+
+ /**
+ * Get the [modifier] column value.
+ *
+ * @return string
+ */
+ public function getDbModifier()
+ {
+ return $this->modifier;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return string
+ */
+ public function getDbValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [extra] column value.
+ *
+ * @return string
+ */
+ public function getDbExtra()
+ {
+ return $this->extra;
+ }
+
+ /**
+ * Get the [playlist_id] column value.
+ *
+ * @return int
+ */
+ public function getDbPlaylistId()
+ {
+ return $this->playlist_id;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::ID;
+ }
+
+ return $this;
+ } // setDbId()
+
+ /**
+ * Set the value of [criteria] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbCriteria($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->criteria !== $v) {
+ $this->criteria = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::CRITERIA;
+ }
+
+ return $this;
+ } // setDbCriteria()
+
+ /**
+ * Set the value of [modifier] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbModifier($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->modifier !== $v) {
+ $this->modifier = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::MODIFIER;
+ }
+
+ return $this;
+ } // setDbModifier()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbValue($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::VALUE;
+ }
+
+ return $this;
+ } // setDbValue()
+
+ /**
+ * Set the value of [extra] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbExtra($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->extra !== $v) {
+ $this->extra = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::EXTRA;
+ }
+
+ return $this;
+ } // setDbExtra()
+
+ /**
+ * Set the value of [playlist_id] column.
+ *
+ * @param int $v new value
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ */
+ public function setDbPlaylistId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->playlist_id !== $v) {
+ $this->playlist_id = $v;
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::PLAYLIST_ID;
+ }
+
+ if ($this->aCcPlaylist !== null && $this->aCcPlaylist->getDbId() !== $v) {
+ $this->aCcPlaylist = null;
+ }
+
+ return $this;
+ } // setDbPlaylistId()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->criteria = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->modifier = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->extra = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->playlist_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CcPlaylistcriteriaPeer::NUM_COLUMNS - CcPlaylistcriteriaPeer::NUM_LAZY_LOAD_COLUMNS).
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CcPlaylistcriteria object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCcPlaylist !== null && $this->playlist_id !== $this->aCcPlaylist->getDbId()) {
+ $this->aCcPlaylist = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CcPlaylistcriteriaPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCcPlaylist = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ CcPlaylistcriteriaQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey())
+ ->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CcPlaylistcriteriaPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCcPlaylist !== null) {
+ if ($this->aCcPlaylist->isModified() || $this->aCcPlaylist->isNew()) {
+ $affectedRows += $this->aCcPlaylist->save($con);
+ }
+ $this->setCcPlaylist($this->aCcPlaylist);
+ }
+
+ if ($this->isNew() ) {
+ $this->modifiedColumns[] = CcPlaylistcriteriaPeer::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(CcPlaylistcriteriaPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistcriteriaPeer::ID.')');
+ }
+
+ $pk = BasePeer::doInsert($criteria, $con);
+ $affectedRows += 1;
+ $this->setDbId($pk); //[IMV] update autoincrement primary key
+ $this->setNew(false);
+ } else {
+ $affectedRows += CcPlaylistcriteriaPeer::doUpdate($this, $con);
+ }
+
+ $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+ return true;
+ } else {
+ $this->validationFailures = $res;
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true
is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true
if all validations pass; array of ValidationFailed
objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCcPlaylist !== null) {
+ if (!$this->aCcPlaylist->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCcPlaylist->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = CcPlaylistcriteriaPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CcPlaylistcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch($pos) {
+ case 0:
+ return $this->getDbId();
+ break;
+ case 1:
+ return $this->getDbCriteria();
+ break;
+ case 2:
+ return $this->getDbModifier();
+ break;
+ case 3:
+ return $this->getDbValue();
+ break;
+ case 4:
+ return $this->getDbExtra();
+ break;
+ case 5:
+ return $this->getDbPlaylistId();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false)
+ {
+ $keys = CcPlaylistcriteriaPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getDbId(),
+ $keys[1] => $this->getDbCriteria(),
+ $keys[2] => $this->getDbModifier(),
+ $keys[3] => $this->getDbValue(),
+ $keys[4] => $this->getDbExtra(),
+ $keys[5] => $this->getDbPlaylistId(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCcPlaylist) {
+ $result['CcPlaylist'] = $this->aCcPlaylist->toArray($keyType, $includeLazyLoadColumns, true);
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CcPlaylistcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch($pos) {
+ case 0:
+ $this->setDbId($value);
+ break;
+ case 1:
+ $this->setDbCriteria($value);
+ break;
+ case 2:
+ $this->setDbModifier($value);
+ break;
+ case 3:
+ $this->setDbValue($value);
+ break;
+ case 4:
+ $this->setDbExtra($value);
+ break;
+ case 5:
+ $this->setDbPlaylistId($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's phpname (e.g. 'AuthorId')
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CcPlaylistcriteriaPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDbCriteria($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDbModifier($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDbValue($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDbExtra($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDbPlaylistId($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::ID)) $criteria->add(CcPlaylistcriteriaPeer::ID, $this->id);
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::CRITERIA)) $criteria->add(CcPlaylistcriteriaPeer::CRITERIA, $this->criteria);
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::MODIFIER)) $criteria->add(CcPlaylistcriteriaPeer::MODIFIER, $this->modifier);
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::VALUE)) $criteria->add(CcPlaylistcriteriaPeer::VALUE, $this->value);
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::EXTRA)) $criteria->add(CcPlaylistcriteriaPeer::EXTRA, $this->extra);
+ if ($this->isColumnModified(CcPlaylistcriteriaPeer::PLAYLIST_ID)) $criteria->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $this->playlist_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
+ $criteria->add(CcPlaylistcriteriaPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getDbId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setDbId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+ return null === $this->getDbId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CcPlaylistcriteria (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false)
+ {
+ $copyObj->setDbCriteria($this->criteria);
+ $copyObj->setDbModifier($this->modifier);
+ $copyObj->setDbValue($this->value);
+ $copyObj->setDbExtra($this->extra);
+ $copyObj->setDbPlaylistId($this->playlist_id);
+
+ $copyObj->setNew(true);
+ $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CcPlaylistcriteria Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CcPlaylistcriteriaPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CcPlaylistcriteriaPeer();
+ }
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a CcPlaylist object.
+ *
+ * @param CcPlaylist $v
+ * @return CcPlaylistcriteria The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCcPlaylist(CcPlaylist $v = null)
+ {
+ if ($v === null) {
+ $this->setDbPlaylistId(NULL);
+ } else {
+ $this->setDbPlaylistId($v->getDbId());
+ }
+
+ $this->aCcPlaylist = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the CcPlaylist object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCcPlaylistcriteria($this);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated CcPlaylist object
+ *
+ * @param PropelPDO Optional Connection object.
+ * @return CcPlaylist The associated CcPlaylist object.
+ * @throws PropelException
+ */
+ public function getCcPlaylist(PropelPDO $con = null)
+ {
+ if ($this->aCcPlaylist === null && ($this->playlist_id !== null)) {
+ $this->aCcPlaylist = CcPlaylistQuery::create()->findPk($this->playlist_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
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCcPlaylist->addCcPlaylistcriterias($this);
+ */
+ }
+ return $this->aCcPlaylist;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->criteria = null;
+ $this->modifier = null;
+ $this->value = null;
+ $this->extra = null;
+ $this->playlist_id = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all collections of referencing foreign keys.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect objects
+ * with circular references. This is currently necessary when using Propel in certain
+ * daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all associated objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCcPlaylist = null;
+ }
+
+ /**
+ * Catches calls to virtual methods
+ */
+ public function __call($name, $params)
+ {
+ if (preg_match('/get(\w+)/', $name, $matches)) {
+ $virtualColumn = $matches[1];
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ // no lcfirst in php<5.3...
+ $virtualColumn[0] = strtolower($virtualColumn[0]);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+ throw new PropelException('Call to undefined method: ' . $name);
+ }
+
+} // BaseCcPlaylistcriteria
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaPeer.php
new file mode 100644
index 000000000..753b365a1
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaPeer.php
@@ -0,0 +1,993 @@
+ array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbPlaylistId', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbPlaylistId', ),
+ BasePeer::TYPE_COLNAME => array (self::ID, self::CRITERIA, self::MODIFIER, self::VALUE, self::EXTRA, self::PLAYLIST_ID, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'PLAYLIST_ID', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'playlist_id', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ private static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbPlaylistId' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbPlaylistId' => 5, ),
+ BasePeer::TYPE_COLNAME => array (self::ID => 0, self::CRITERIA => 1, self::MODIFIER => 2, self::VALUE => 3, self::EXTRA => 4, self::PLAYLIST_ID => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'PLAYLIST_ID' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'playlist_id' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ static public function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = self::getFieldNames($toType);
+ $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
+ }
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ */
+
+ static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, self::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+ return self::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CcPlaylistcriteriaPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CcPlaylistcriteriaPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::ID);
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::CRITERIA);
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::MODIFIER);
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::VALUE);
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::EXTRA);
+ $criteria->addSelectColumn(CcPlaylistcriteriaPeer::PLAYLIST_ID);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CRITERIA');
+ $criteria->addSelectColumn($alias . '.MODIFIER');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.EXTRA');
+ $criteria->addSelectColumn($alias . '.PLAYLIST_ID');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+ return $count;
+ }
+ /**
+ * Method to select one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CcPlaylistcriteria
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CcPlaylistcriteriaPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+ return null;
+ }
+ /**
+ * Method to do selects.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CcPlaylistcriteriaPeer::populateObjects(CcPlaylistcriteriaPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CcPlaylistcriteria $value A CcPlaylistcriteria object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool(CcPlaylistcriteria $obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getDbId();
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CcPlaylistcriteria object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CcPlaylistcriteria) {
+ $key = (string) $value->getDbId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcPlaylistcriteria object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CcPlaylistcriteria Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(self::$instances[$key])) {
+ return self::$instances[$key];
+ }
+ }
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ self::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to cc_playlistcriteria
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or NULL if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CcPlaylistcriteriaPeer::getOMClass(false);
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CcPlaylistcriteriaPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CcPlaylistcriteria object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CcPlaylistcriteriaPeer::NUM_COLUMNS;
+ } else {
+ $cls = CcPlaylistcriteriaPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CcPlaylistcriteriaPeer::addInstanceToPool($obj, $key);
+ }
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the number of rows matching criteria, joining the related CcPlaylist table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCcPlaylist(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CcPlaylistcriteria objects pre-filled with their CcPlaylist objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CcPlaylistcriteria objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCcPlaylist(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(self::DATABASE_NAME);
+ }
+
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ $startcol = (CcPlaylistcriteriaPeer::NUM_COLUMNS - CcPlaylistcriteriaPeer::NUM_LAZY_LOAD_COLUMNS);
+ CcPlaylistPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CcPlaylistcriteriaPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CcPlaylistcriteriaPeer::getOMClass(false);
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CcPlaylistcriteriaPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CcPlaylistPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CcPlaylistPeer::getOMClass(false);
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CcPlaylistPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CcPlaylistcriteria) to $obj2 (CcPlaylist)
+ $obj2->addCcPlaylistcriteria($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CcPlaylistcriteria objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CcPlaylistcriteria objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(self::DATABASE_NAME);
+ }
+
+ CcPlaylistcriteriaPeer::addSelectColumns($criteria);
+ $startcol2 = (CcPlaylistcriteriaPeer::NUM_COLUMNS - CcPlaylistcriteriaPeer::NUM_LAZY_LOAD_COLUMNS);
+
+ CcPlaylistPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS);
+
+ $criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CcPlaylistcriteriaPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CcPlaylistcriteriaPeer::getOMClass(false);
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CcPlaylistcriteriaPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined CcPlaylist rows
+
+ $key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CcPlaylistPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CcPlaylistPeer::getOMClass(false);
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CcPlaylistPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CcPlaylistcriteria) to the collection in $obj2 (CcPlaylist)
+ $obj2->addCcPlaylistcriteria($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+ return $results;
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCcPlaylistcriteriaPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCcPlaylistcriteriaPeer::TABLE_NAME))
+ {
+ $dbMap->addTableObject(new CcPlaylistcriteriaTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is tranalted into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CcPlaylistcriteriaPeer::CLASS_DEFAULT : CcPlaylistcriteriaPeer::OM_CLASS;
+ }
+
+ /**
+ * Method perform an INSERT on the database, given a CcPlaylistcriteria or Criteria object.
+ *
+ * @param mixed $values Criteria or CcPlaylistcriteria object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CcPlaylistcriteria object
+ }
+
+ if ($criteria->containsKey(CcPlaylistcriteriaPeer::ID) && $criteria->keyContainsValue(CcPlaylistcriteriaPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistcriteriaPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch(PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Method perform an UPDATE on the database, given a CcPlaylistcriteria or Criteria object.
+ *
+ * @param mixed $values Criteria or CcPlaylistcriteria object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(self::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CcPlaylistcriteriaPeer::ID);
+ $value = $criteria->remove(CcPlaylistcriteriaPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CcPlaylistcriteriaPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CcPlaylistcriteria object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Method to DELETE all rows from the cc_playlistcriteria table.
+ *
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll($con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CcPlaylistcriteriaPeer::TABLE_NAME, $con, CcPlaylistcriteriaPeer::DATABASE_NAME);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CcPlaylistcriteriaPeer::clearInstancePool();
+ CcPlaylistcriteriaPeer::clearRelatedInstancePool();
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Method perform a DELETE on the database, given a CcPlaylistcriteria or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CcPlaylistcriteria object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CcPlaylistcriteriaPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof CcPlaylistcriteria) { // it's a model object
+ // invalidate the cache for this single object
+ CcPlaylistcriteriaPeer::removeInstanceFromPool($values);
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(self::DATABASE_NAME);
+ $criteria->add(CcPlaylistcriteriaPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CcPlaylistcriteriaPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CcPlaylistcriteriaPeer::clearRelatedInstancePool();
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CcPlaylistcriteria object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CcPlaylistcriteria $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate(CcPlaylistcriteria $obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CcPlaylistcriteriaPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CcPlaylistcriteriaPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->containsColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CcPlaylistcriteriaPeer::DATABASE_NAME, CcPlaylistcriteriaPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CcPlaylistcriteria
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
+ $criteria->add(CcPlaylistcriteriaPeer::ID, $pk);
+
+ $v = CcPlaylistcriteriaPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
+ $criteria->add(CcPlaylistcriteriaPeer::ID, $pks, Criteria::IN);
+ $objs = CcPlaylistcriteriaPeer::doSelect($criteria, $con);
+ }
+ return $objs;
+ }
+
+} // BaseCcPlaylistcriteriaPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCcPlaylistcriteriaPeer::buildTableMap();
+
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaQuery.php
new file mode 100644
index 000000000..1216e6cf7
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcriteriaQuery.php
@@ -0,0 +1,372 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+ return $query;
+ }
+
+ /**
+ * Find object by primary key
+ * Use instance pooling to avoid a database query if the object exists
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CcPlaylistcriteria|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ((null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
+ // the object is alredy in the instance pool
+ return $obj;
+ } else {
+ // the object has not been requested yet, or the formatter is not an object formatter
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->getSelectStatement($con);
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ return $this
+ ->filterByPrimaryKeys($keys)
+ ->find($con);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * @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
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbId($dbId = null, $comparison = null)
+ {
+ if (is_array($dbId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $dbId, $comparison);
+ }
+
+ /**
+ * Filter the query on the criteria column
+ *
+ * @param string $dbCriteria 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 CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbCriteria($dbCriteria = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbCriteria)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbCriteria)) {
+ $dbCriteria = str_replace('*', '%', $dbCriteria);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::CRITERIA, $dbCriteria, $comparison);
+ }
+
+ /**
+ * Filter the query on the modifier column
+ *
+ * @param string $dbModifier 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 CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbModifier($dbModifier = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbModifier)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbModifier)) {
+ $dbModifier = str_replace('*', '%', $dbModifier);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::MODIFIER, $dbModifier, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * @param string $dbValue 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 CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbValue($dbValue = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbValue)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbValue)) {
+ $dbValue = str_replace('*', '%', $dbValue);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::VALUE, $dbValue, $comparison);
+ }
+
+ /**
+ * Filter the query on the extra column
+ *
+ * @param string $dbExtra 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 CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbExtra($dbExtra = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbExtra)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbExtra)) {
+ $dbExtra = str_replace('*', '%', $dbExtra);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::EXTRA, $dbExtra, $comparison);
+ }
+
+ /**
+ * Filter the query on the playlist_id column
+ *
+ * @param int|array $dbPlaylistId 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 CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByDbPlaylistId($dbPlaylistId = null, $comparison = null)
+ {
+ if (is_array($dbPlaylistId)) {
+ $useMinMax = false;
+ if (isset($dbPlaylistId['min'])) {
+ $this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbPlaylistId['max'])) {
+ $this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId, $comparison);
+ }
+
+ /**
+ * Filter the query by a related CcPlaylist object
+ *
+ * @param CcPlaylist $ccPlaylist the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function filterByCcPlaylist($ccPlaylist, $comparison = null)
+ {
+ return $this
+ ->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $ccPlaylist->getDbId(), $comparison);
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CcPlaylist relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function joinCcPlaylist($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CcPlaylist');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CcPlaylist');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CcPlaylist relation CcPlaylist object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcPlaylistQuery A secondary query class using the current class as primary query
+ */
+ public function useCcPlaylistQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCcPlaylist($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', 'CcPlaylistQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CcPlaylistcriteria $ccPlaylistcriteria Object to remove from the list of results
+ *
+ * @return CcPlaylistcriteriaQuery The current query, for fluid interface
+ */
+ public function prune($ccPlaylistcriteria = null)
+ {
+ if ($ccPlaylistcriteria) {
+ $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $ccPlaylistcriteria->getDbId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+} // BaseCcPlaylistcriteriaQuery
diff --git a/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml b/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml
new file mode 100644
index 000000000..d2b4d7a0d
--- /dev/null
+++ b/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml
@@ -0,0 +1,52 @@
+