diff --git a/application/Bootstrap.php b/application/Bootstrap.php
new file mode 100644
index 000000000..6ae138cb6
--- /dev/null
+++ b/application/Bootstrap.php
@@ -0,0 +1,59 @@
+getMessage()." ".$CC_DBC->getUserInfo()."\n";
+ exit(1);
+}
+$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
+
+class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
+{
+ protected function _initDoctype()
+ {
+ $this->bootstrap('view');
+ $view = $this->getResource('view');
+ $view->doctype('XHTML1_STRICT');
+ }
+
+ protected function _initHeadLink()
+ {
+ $view = $this->getResource('view');
+
+ $view->headLink()->appendStylesheet('/css/excite-bike/excite_bike.css');
+ }
+
+ protected function _initHeadScript()
+ {
+ $view = $this->getResource('view');
+ $view->headScript()->appendFile('/js/libs/jquery-1.4.4.min.js','text/javascript');
+ $view->headScript()->appendFile('/js/libs/jquery-ui-1.8.5.min.js','text/javascript');
+ }
+
+}
+
diff --git a/application/configs/ACL.php b/application/configs/ACL.php
new file mode 100644
index 000000000..61f657bae
--- /dev/null
+++ b/application/configs/ACL.php
@@ -0,0 +1,33 @@
+addRole(new Zend_Acl_Role('guest'))
+ ->addRole(new Zend_Acl_Role('host'), 'guest')
+ ->addRole(new Zend_Acl_Role('admin'), 'host');
+
+$ccAcl->add(new Zend_Acl_Resource('library'))
+ ->add(new Zend_Acl_Resource('index'))
+ ->add(new Zend_Acl_Resource('error'))
+ ->add(new Zend_Acl_Resource('login'))
+ ->add(new Zend_Acl_Resource('playlist'))
+ ->add(new Zend_Acl_Resource('plupload'))
+ ->add(new Zend_Acl_Resource('schedule'))
+ ->add(new Zend_Acl_Resource('search'));
+
+/** Creating permissions */
+$ccAcl->allow('guest', 'index')
+ ->allow('guest', 'login')
+ ->allow('guest', 'error')
+ ->allow('guest', 'library')
+ ->allow('guest', 'search')
+ ->allow('host', 'plupload')
+ ->allow('host', 'playlist')
+ ->allow('host', 'schedule');
+
+$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);
+
+$front = Zend_Controller_Front::getInstance();
+$front->registerPlugin($aclPlugin);
diff --git a/application/configs/application.ini b/application/configs/application.ini
new file mode 100644
index 000000000..88feac347
--- /dev/null
+++ b/application/configs/application.ini
@@ -0,0 +1,28 @@
+[production]
+phpSettings.display_startup_errors = 0
+phpSettings.display_errors = 0
+includePaths.library = APPLICATION_PATH "/../library"
+bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
+bootstrap.class = "Bootstrap"
+appnamespace = "Application"
+resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
+resources.frontController.params.displayExceptions = 0
+resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
+resources.view[] =
+resources.db.adapter = "Pdo_Pgsql"
+resources.db.params.charset = "utf8"
+resources.db.params.host = "localhost"
+resources.db.params.username = "campcaster"
+resources.db.params.password = "campcaster"
+resources.db.params.dbname = "campcaster"
+
+[staging : production]
+
+[testing : production]
+phpSettings.display_startup_errors = 1
+phpSettings.display_errors = 1
+
+[development : production]
+phpSettings.display_startup_errors = 1
+phpSettings.display_errors = 1
+resources.frontController.params.displayExceptions = 1
diff --git a/application/configs/classmap-propel-config.php b/application/configs/classmap-propel-config.php
new file mode 100644
index 000000000..9e36b34fc
--- /dev/null
+++ b/application/configs/classmap-propel-config.php
@@ -0,0 +1,95 @@
+ 'campcaster/map/CcAccessTableMap.php',
+ 'CcAccessPeer' => 'campcaster/CcAccessPeer.php',
+ 'CcAccess' => 'campcaster/CcAccess.php',
+ 'CcAccessQuery' => 'campcaster/CcAccessQuery.php',
+ 'BaseCcAccessPeer' => 'campcaster/om/BaseCcAccessPeer.php',
+ 'BaseCcAccess' => 'campcaster/om/BaseCcAccess.php',
+ 'BaseCcAccessQuery' => 'campcaster/om/BaseCcAccessQuery.php',
+ 'CcBackupTableMap' => 'campcaster/map/CcBackupTableMap.php',
+ 'CcBackupPeer' => 'campcaster/CcBackupPeer.php',
+ 'CcBackup' => 'campcaster/CcBackup.php',
+ 'CcBackupQuery' => 'campcaster/CcBackupQuery.php',
+ 'BaseCcBackupPeer' => 'campcaster/om/BaseCcBackupPeer.php',
+ 'BaseCcBackup' => 'campcaster/om/BaseCcBackup.php',
+ 'BaseCcBackupQuery' => 'campcaster/om/BaseCcBackupQuery.php',
+ 'CcFilesTableMap' => 'campcaster/map/CcFilesTableMap.php',
+ 'CcFilesPeer' => 'campcaster/CcFilesPeer.php',
+ 'CcFiles' => 'campcaster/CcFiles.php',
+ 'CcFilesQuery' => 'campcaster/CcFilesQuery.php',
+ 'BaseCcFilesPeer' => 'campcaster/om/BaseCcFilesPeer.php',
+ 'BaseCcFiles' => 'campcaster/om/BaseCcFiles.php',
+ 'BaseCcFilesQuery' => 'campcaster/om/BaseCcFilesQuery.php',
+ 'CcPermsTableMap' => 'campcaster/map/CcPermsTableMap.php',
+ 'CcPermsPeer' => 'campcaster/CcPermsPeer.php',
+ 'CcPerms' => 'campcaster/CcPerms.php',
+ 'CcPermsQuery' => 'campcaster/CcPermsQuery.php',
+ 'BaseCcPermsPeer' => 'campcaster/om/BaseCcPermsPeer.php',
+ 'BaseCcPerms' => 'campcaster/om/BaseCcPerms.php',
+ 'BaseCcPermsQuery' => 'campcaster/om/BaseCcPermsQuery.php',
+ 'CcShowTableMap' => 'campcaster/map/CcShowTableMap.php',
+ 'CcShowPeer' => 'campcaster/CcShowPeer.php',
+ 'CcShow' => 'campcaster/CcShow.php',
+ 'CcShowQuery' => 'campcaster/CcShowQuery.php',
+ 'BaseCcShowPeer' => 'campcaster/om/BaseCcShowPeer.php',
+ 'BaseCcShow' => 'campcaster/om/BaseCcShow.php',
+ 'BaseCcShowQuery' => 'campcaster/om/BaseCcShowQuery.php',
+ 'CcPlaylistTableMap' => 'campcaster/map/CcPlaylistTableMap.php',
+ 'CcPlaylistPeer' => 'campcaster/CcPlaylistPeer.php',
+ 'CcPlaylist' => 'campcaster/CcPlaylist.php',
+ 'CcPlaylistQuery' => 'campcaster/CcPlaylistQuery.php',
+ 'BaseCcPlaylistPeer' => 'campcaster/om/BaseCcPlaylistPeer.php',
+ 'BaseCcPlaylist' => 'campcaster/om/BaseCcPlaylist.php',
+ 'BaseCcPlaylistQuery' => 'campcaster/om/BaseCcPlaylistQuery.php',
+ 'CcPlaylistcontentsTableMap' => 'campcaster/map/CcPlaylistcontentsTableMap.php',
+ 'CcPlaylistcontentsPeer' => 'campcaster/CcPlaylistcontentsPeer.php',
+ 'CcPlaylistcontents' => 'campcaster/CcPlaylistcontents.php',
+ 'CcPlaylistcontentsQuery' => 'campcaster/CcPlaylistcontentsQuery.php',
+ 'BaseCcPlaylistcontentsPeer' => 'campcaster/om/BaseCcPlaylistcontentsPeer.php',
+ 'BaseCcPlaylistcontents' => 'campcaster/om/BaseCcPlaylistcontents.php',
+ 'BaseCcPlaylistcontentsQuery' => 'campcaster/om/BaseCcPlaylistcontentsQuery.php',
+ 'CcPrefTableMap' => 'campcaster/map/CcPrefTableMap.php',
+ 'CcPrefPeer' => 'campcaster/CcPrefPeer.php',
+ 'CcPref' => 'campcaster/CcPref.php',
+ 'CcPrefQuery' => 'campcaster/CcPrefQuery.php',
+ 'BaseCcPrefPeer' => 'campcaster/om/BaseCcPrefPeer.php',
+ 'BaseCcPref' => 'campcaster/om/BaseCcPref.php',
+ 'BaseCcPrefQuery' => 'campcaster/om/BaseCcPrefQuery.php',
+ 'CcScheduleTableMap' => 'campcaster/map/CcScheduleTableMap.php',
+ 'CcSchedulePeer' => 'campcaster/CcSchedulePeer.php',
+ 'CcSchedule' => 'campcaster/CcSchedule.php',
+ 'CcScheduleQuery' => 'campcaster/CcScheduleQuery.php',
+ 'BaseCcSchedulePeer' => 'campcaster/om/BaseCcSchedulePeer.php',
+ 'BaseCcSchedule' => 'campcaster/om/BaseCcSchedule.php',
+ 'BaseCcScheduleQuery' => 'campcaster/om/BaseCcScheduleQuery.php',
+ 'CcSessTableMap' => 'campcaster/map/CcSessTableMap.php',
+ 'CcSessPeer' => 'campcaster/CcSessPeer.php',
+ 'CcSess' => 'campcaster/CcSess.php',
+ 'CcSessQuery' => 'campcaster/CcSessQuery.php',
+ 'BaseCcSessPeer' => 'campcaster/om/BaseCcSessPeer.php',
+ 'BaseCcSess' => 'campcaster/om/BaseCcSess.php',
+ 'BaseCcSessQuery' => 'campcaster/om/BaseCcSessQuery.php',
+ 'CcSmembTableMap' => 'campcaster/map/CcSmembTableMap.php',
+ 'CcSmembPeer' => 'campcaster/CcSmembPeer.php',
+ 'CcSmemb' => 'campcaster/CcSmemb.php',
+ 'CcSmembQuery' => 'campcaster/CcSmembQuery.php',
+ 'BaseCcSmembPeer' => 'campcaster/om/BaseCcSmembPeer.php',
+ 'BaseCcSmemb' => 'campcaster/om/BaseCcSmemb.php',
+ 'BaseCcSmembQuery' => 'campcaster/om/BaseCcSmembQuery.php',
+ 'CcSubjsTableMap' => 'campcaster/map/CcSubjsTableMap.php',
+ 'CcSubjsPeer' => 'campcaster/CcSubjsPeer.php',
+ 'CcSubjs' => 'campcaster/CcSubjs.php',
+ 'CcSubjsQuery' => 'campcaster/CcSubjsQuery.php',
+ 'BaseCcSubjsPeer' => 'campcaster/om/BaseCcSubjsPeer.php',
+ 'BaseCcSubjs' => 'campcaster/om/BaseCcSubjs.php',
+ 'BaseCcSubjsQuery' => 'campcaster/om/BaseCcSubjsQuery.php',
+ 'CcTransTableMap' => 'campcaster/map/CcTransTableMap.php',
+ 'CcTransPeer' => 'campcaster/CcTransPeer.php',
+ 'CcTrans' => 'campcaster/CcTrans.php',
+ 'CcTransQuery' => 'campcaster/CcTransQuery.php',
+ 'BaseCcTransPeer' => 'campcaster/om/BaseCcTransPeer.php',
+ 'BaseCcTrans' => 'campcaster/om/BaseCcTrans.php',
+ 'BaseCcTransQuery' => 'campcaster/om/BaseCcTransQuery.php',
+);
\ No newline at end of file
diff --git a/application/configs/conf.php b/application/configs/conf.php
new file mode 100644
index 000000000..76cfd86ee
--- /dev/null
+++ b/application/configs/conf.php
@@ -0,0 +1,193 @@
+ array(
+ 'username' => 'campcaster',
+ 'password' => 'campcaster',
+ 'hostspec' => 'localhost',
+ 'phptype' => 'pgsql',
+ 'database' => 'campcaster',
+ ),
+
+ // Name of the web server user
+ 'webServerUser' => 'www-data',
+
+ // prefix for table names in the database
+ 'tblNamePrefix' => 'cc_',
+
+ /* ================================================ storage configuration */
+
+ 'apiKey' => array('AAA'),
+
+ // main directory for storing binary media files
+ 'storageDir' => dirname(__FILE__).'/../../stor',
+
+ // directory for temporary files
+ 'bufferDir' => dirname(__FILE__).'/../../stor/buffer',
+
+ // directory for incomplete transferred files
+ 'transDir' => dirname(__FILE__).'/trans',
+
+ // directory for symlinks to accessed files
+ 'accessDir' => dirname(__FILE__).'/access',
+ 'cronDir' => dirname(__FILE__).'/backend/cron',
+
+ "rootDir" => dirname(__FILE__),
+ "smartyTemplate" => dirname(__FILE__)."/htmlUI/templates",
+ "smartyTemplateCompiled" => dirname(__FILE__)."/htmlUI/templates_c",
+ 'pearPath' => dirname(__FILE__).'/3rd_party/php/pear',
+ 'zendPath' => dirname(__FILE__).'/3rd_party/php/Zend',
+ 'phingPath' => dirname(__FILE__).'/3rd_party/php/phing',
+ 'LogPath' => dirname(__FILE__).'/3rd_party/php/Log',
+
+ // secret token cookie name
+ 'authCookieName'=> 'campcaster_session_id',
+
+ // name of admin group
+ //'AdminsGr' => 'Admins',
+
+ // name of station preferences group
+ 'StationPrefsGr'=> 'StationPrefs',
+
+ // name of 'all users' group
+ //'AllGr' => 'All',
+ 'TrashName' => 'trash_',
+
+ // enable/disable validator
+ 'validate' => TRUE,
+
+ // enable/disable safe delete (move to trash)
+ 'useTrash' => FALSE,
+
+ /* ==================================================== URL configuration */
+ // path-URL-part of storageServer base dir
+ 'storageUrlPath' => '/campcaster/backend',
+
+ // XMLRPC server script address relative to storageUrlPath
+ 'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
+
+ // host and port of storageServer
+ 'storageUrlHost' => 'localhost',
+ 'storageUrlPort' => 80,
+
+ /* ================================================ remote link configuration */
+ // path-URL-part of remote server base dir
+ 'archiveUrlPath' => '/campcaster/backend',
+
+ // XMLRPC server script address relative to archiveUrlPath
+ 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
+
+ // host and port of archiveServer
+ 'archiveUrlHost' => 'localhost',
+// 'archiveUrlHost' => '192.168.30.166',
+ 'archiveUrlPort' => 80,
+
+ // account info for login to archive
+ 'archiveAccountLogin' => 'root',
+ 'archiveAccountPass' => 'q',
+
+ /* ============================================== scheduler configuration */
+ 'schedulerUrlPath' => '',
+ 'schedulerXMLRPC' => 'RC2',
+ 'schedulerUrlHost' => 'localhost',
+ 'schedulerUrlPort' => 3344,
+ 'schedulerPass' => 'change_me',
+
+ /* ==================================== application-specific configuration */
+ 'objtypes' => array(
+ 'Storage' => array(/*'Folder',*/ 'File' /*, 'Replica'*/),
+ 'File' => array(),
+ 'audioclip' => array(),
+ 'playlist' => array(),
+// 'Replica' => array(),
+ ),
+ 'allowedActions'=> array(
+ 'File' => array('editPrivs', 'write', 'read'),
+ 'audioclip' => array('editPrivs', 'write', 'read'),
+ 'playlist' => array('editPrivs', 'write', 'read'),
+// 'Replica' => array('editPrivs', 'write', 'read'),
+// '_class' => array('editPrivs', 'write', 'read'),
+ ),
+ 'allActions' => array(
+ 'editPrivs', 'write', 'read', /*'classes',*/ 'subjects'
+ ),
+
+ /* ============================================== auxiliary configuration */
+ 'tmpRootPass' => 'q',
+
+ /* =================================================== cron configuration */
+ 'cronUserName' => 'www-data',
+# 'lockfile' => dirname(__FILE__).'/cron/cron.lock',
+ 'lockfile' => dirname(__FILE__).'/stor/buffer/cron.lock',
+ 'cronfile' => dirname(__FILE__).'/cron/croncall.php',
+ 'paramdir' => dirname(__FILE__).'/cron/params',
+ 'systemPrefId' => "0", // ID for system prefs in prefs table
+);
+
+// Add database table names
+$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
+$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
+$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
+$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
+$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
+$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
+$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
+$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
+$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
+$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
+$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
+$CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup';
+$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
+
+$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
+$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
+$CC_CONFIG['transSequence'] = $CC_CONFIG['transTable'].'_id';
+$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
+$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
+$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
+$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
+
+// System users/groups - they cannot be deleted
+$CC_CONFIG['sysSubjs'] = array(
+ 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
+);
+
+// Add libs to the PHP path
+$old_include_path = get_include_path();
+set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
+ .PATH_SEPARATOR.$CC_CONFIG['zendPath']
+ .PATH_SEPARATOR.$old_include_path);
+
+// Check that all the required directories exist.
+//foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'cronDir') as $d) {
+// $test = file_exists($CC_CONFIG[$d]);
+// if ( $test === FALSE ) {
+// echo " * Error: directory {$CC_CONFIG[$d]} is missing.\n";
+// echo " * Please run the install script again.\n";
+// exit(1);
+// } else {
+// $rp = realpath($CC_CONFIG[$d]);
+// }
+// $CC_CONFIG[$d] = $rp;
+//}
+
+// Check that htmlUI/templates_c has the right permissions
+//$ss=@stat($CC_CONFIG["smartyTemplateCompiled"]);
+//$groupOwner = (function_exists('posix_getgrgid'))?@posix_getgrgid($ss['gid']):'';
+//if (!empty($groupOwner) && ($groupOwner["name"] != $CC_CONFIG["webServerUser"])) {
+// echo " * Error: Your directory permissions for {$CC_CONFIG['smartyTemplateCompiled']} are not set correctly.
\n";
+// echo " * The group perms need to be set to the web server user, in this case '{$CC_CONFIG['webServerUser']}'.
\n";
+// exit(1);
+//}
+//$fileperms=@fileperms($CC_CONFIG["smartyTemplateCompiled"]);
+//if (!($fileperms & 0x0400)) {
+// echo " * Error: Sticky bit not set for {$CC_CONFIG['smartyTemplateCompiled']}.
\n";
+// exit(1);
+//}
+?>
diff --git a/application/configs/constants.php b/application/configs/constants.php
new file mode 100644
index 000000000..7dfa420aa
--- /dev/null
+++ b/application/configs/constants.php
@@ -0,0 +1,22 @@
+ 'Home',
+ 'title' => 'Go Home',
+ 'module' => 'default',
+ 'controller' => 'index',
+ 'action' => 'index',
+ 'order' => -100 // make sure home is the first page
+ ),
+ array(
+ 'label' => 'Playlists',
+ 'module' => 'default',
+ 'controller' => 'Playlist',
+ 'action' => 'index',
+ 'pages' => array(
+ array(
+ 'label' => 'Edit',
+ 'module' => 'default',
+ 'controller' => 'Playlist',
+ 'action' => 'edit',
+ 'visible' => false
+ )
+ )
+ ),
+ array(
+ 'label' => 'Media Library',
+ 'module' => 'default',
+ 'controller' => 'Library',
+ 'action' => 'index',
+ 'pages' => array(
+ array(
+ 'label' => 'Add Audio',
+ 'module' => 'default',
+ 'controller' => 'Plupload',
+ 'action' => 'plupload'
+ ),
+ array(
+ 'label' => 'Search',
+ 'module' => 'default',
+ 'controller' => 'Search',
+ 'action' => 'display'
+ )
+ )
+ ),
+ array(
+ 'label' => 'Schedule',
+ 'module' => 'default',
+ 'controller' => 'Schedule',
+ 'action' => 'index'
+ ),
+ array(
+ 'label' => 'Logout',
+ 'module' => 'default',
+ 'controller' => 'Login',
+ 'action' => 'logout'
+ )
+);
+
+// Create container from array
+$container = new Zend_Navigation($pages);
+
+//store it in the registry:
+Zend_Registry::set('Zend_Navigation', $container);
diff --git a/application/configs/propel-config.php b/application/configs/propel-config.php
new file mode 100644
index 000000000..52b446655
--- /dev/null
+++ b/application/configs/propel-config.php
@@ -0,0 +1,20 @@
+
+ array (
+ 'campcaster' =>
+ array (
+ 'adapter' => 'pgsql',
+ 'connection' =>
+ array (
+ 'dsn' => 'pgsql:host=localhost;port=5432;dbname=campcaster;user=campcaster;password=campcaster',
+ ),
+ ),
+ 'default' => 'campcaster',
+ ),
+ 'generator_version' => '1.5.2',
+);
+$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-propel-config.php');
+return $conf;
\ No newline at end of file
diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php
new file mode 100644
index 000000000..70f73ee37
--- /dev/null
+++ b/application/controllers/ErrorController.php
@@ -0,0 +1,58 @@
+_getParam('error_handler');
+
+ switch ($errors->type) {
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+
+ // 404 error -- controller or action not found
+ $this->getResponse()->setHttpResponseCode(404);
+ $this->view->message = 'Page not found';
+ break;
+ default:
+ // application error
+ $this->getResponse()->setHttpResponseCode(500);
+ $this->view->message = 'Application error';
+ break;
+ }
+
+ // Log exception, if logger available
+ if ($log = $this->getLog()) {
+ $log->crit($this->view->message, $errors->exception);
+ }
+
+ // conditionally display exceptions
+ if ($this->getInvokeArg('displayExceptions') == true) {
+ $this->view->exception = $errors->exception;
+ }
+
+ $this->view->request = $errors->request;
+ }
+
+ public function getLog()
+ {
+ $bootstrap = $this->getInvokeArg('bootstrap');
+ if (!$bootstrap->hasPluginResource('Log')) {
+ return false;
+ }
+ $log = $bootstrap->getResource('Log');
+ return $log;
+ }
+
+ public function deniedAction()
+ {
+ // action body
+ }
+
+
+}
+
+
+
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
new file mode 100644
index 000000000..1f5135329
--- /dev/null
+++ b/application/controllers/IndexController.php
@@ -0,0 +1,39 @@
+_forward('index', 'login');
+ }
+
+ public function mainAction()
+ {
+ $this->_helper->layout->setLayout('layout');
+ }
+
+ public function newfieldAction()
+ {
+ // action body
+ }
+
+ public function displayAction()
+ {
+ // action body
+ }
+
+
+}
+
+
+
+
+
+
+
diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php
new file mode 100644
index 000000000..a36941194
--- /dev/null
+++ b/application/controllers/LibraryController.php
@@ -0,0 +1,104 @@
+hasIdentity())
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('contents', 'html')
+ ->addActionContext('plupload', 'html')
+ ->addActionContext('upload', 'json')
+ ->addActionContext('delete', 'json')
+ ->initContext();
+
+ $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
+ }
+
+ public function indexAction()
+ {
+ $this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/campcaster/library/library.js','text/javascript');
+
+ $this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
+
+ $this->_helper->actionStack('context-menu', 'library');
+ }
+
+ public function contextMenuAction()
+ {
+ $pl_sess = $this->pl_sess;
+ $contextMenu;
+
+ $contextMenu[] = array('action' => '/Library/delete', 'text' => 'Delete');
+
+ if(isset($pl_sess->id))
+ $contextMenu[] = array('action' => '/Playlist/add-item', 'text' => 'Add To Playlist');
+
+ $this->view->menu = $contextMenu;
+
+ $this->_helper->actionStack('contents', 'library');
+ }
+
+ public function deleteAction()
+ {
+ $id = $this->_getParam('id');
+
+ if (!is_null($id)) {
+ $file = StoredFile::Recall($id);
+
+ if (PEAR::isError($file)) {
+ die('{"jsonrpc" : "2.0", "error" : {"message": ' + $file->getMessage() + '}}');
+ }
+ else if(is_null($file)) {
+ die('{"jsonrpc" : "2.0", "error" : {"message": "file doesn\'t exist"}}');
+ }
+
+ $res = $file->delete();
+
+ if (PEAR::isError($res)) {
+ die('{"jsonrpc" : "2.0", "error" : {"message": ' + $res->getMessage() + '}}');
+ }
+ }
+ else {
+ die('{"jsonrpc" : "2.0", "error" : {"message": "file doesn\'t exist"}}');
+ }
+
+ die('{"jsonrpc" : "2.0"}');
+ }
+
+ public function contentsAction()
+ {
+ $query["category"] = $this->_getParam('ob', "dc:creator");
+ $query["order"] = $this->_getParam('order', "asc");
+
+ $this->view->files = StoredFile::getFiles($query);
+ }
+
+ public function searchAction()
+ {
+ // action body
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/controllers/LoginController.php b/application/controllers/LoginController.php
new file mode 100644
index 000000000..0a41850b5
--- /dev/null
+++ b/application/controllers/LoginController.php
@@ -0,0 +1,96 @@
+hasIdentity())
+ {
+ $this->_redirect('library/index');
+ }
+
+ //uses separate layout without a navigation.
+ $this->_helper->layout->setLayout('login');
+
+ $request = $this->getRequest();
+ $form = new Application_Form_Login();
+
+ $errorMessage = "";
+
+ if($request->isPost())
+ {
+ if($form->isValid($request->getPost()))
+ {
+
+ $authAdapter = $this->getAuthAdapter();
+
+ # get the username and password from the form
+ $username = $form->getValue('username');
+ $password = $form->getValue('password');
+
+ # pass to the adapter the submitted username and password
+ $authAdapter->setIdentity($username)
+ ->setCredential($password);
+
+ $auth = Zend_Auth::getInstance();
+ $result = $auth->authenticate($authAdapter);
+
+ # is the user a valid one?
+ if($result->isValid())
+ {
+ # all info about this user from the login table
+ # omit only the password, we don't need that
+ $userInfo = $authAdapter->getResultRowObject(null, 'password');
+
+ # the default storage is a session with namespace Zend_Auth
+ $authStorage = $auth->getStorage();
+ $authStorage->write($userInfo);
+
+ $this->_redirect('library/index');
+ }
+ else
+ {
+ $errorMessage = "Wrong username or password provided. Please try again.";
+ }
+ }
+ }
+
+ $this->view->errorMessage = $errorMessage;
+ $this->view->form = $form;
+
+ }
+
+ public function logoutAction()
+ {
+ Zend_Auth::getInstance()->clearIdentity();
+ $this->_redirect('login/index');
+ }
+
+ /**
+ * Gets the adapter for authentication against a database table
+ *
+ * @return object
+ */
+ protected function getAuthAdapter()
+ {
+ $dbAdapter = Zend_Db_Table::getDefaultAdapter();
+ $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
+
+ $authAdapter->setTableName('cc_subjs')
+ ->setIdentityColumn('login')
+ ->setCredentialColumn('pass')
+ ->setCredentialTreatment('MD5(?)');
+
+ return $authAdapter;
+ }
+
+}
+
+
+
diff --git a/application/controllers/PlaylistController.php b/application/controllers/PlaylistController.php
new file mode 100644
index 000000000..b4768b71f
--- /dev/null
+++ b/application/controllers/PlaylistController.php
@@ -0,0 +1,255 @@
+hasIdentity())
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('add-item', 'json')
+ ->addActionContext('delete-item', 'html')
+ ->addActionContext('set-fade', 'json')
+ ->addActionContext('set-cue', 'json')
+ ->addActionContext('move-item', 'html')
+ ->initContext();
+
+ $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
+ }
+
+ public function indexAction()
+ {
+
+ }
+
+ public function newAction()
+ {
+ $pl_sess = $this->pl_sess;
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+
+ $pl = new Playlist();
+ $pl_id = $pl->create("Test Zend Auth");
+ $pl->setPLMetaData('dc:creator', $userInfo->login);
+ $pl->lock($userInfo->id);
+
+ //set this playlist as active id.
+ $pl_sess->id = $pl_id;
+
+ $this->_helper->redirector('metadata');
+ }
+
+ public function metadataAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ $request = $this->getRequest();
+ $form = new Application_Form_PlaylistMetadata();
+
+ if ($this->getRequest()->isPost()) {
+ if ($form->isValid($request->getPost())) {
+
+ $formdata = $form->getValues();
+
+ $pl = Playlist::Recall($pl_sess->id);
+ $pl->setPLMetaData(UI_MDATA_KEY_TITLE, $formdata["title"]);
+
+ if(isset($formdata["description"]))
+ $pl->setPLMetaData(UI_MDATA_KEY_DESCRIPTION, $formdata["description"]);
+
+ $this->_helper->redirector('edit');
+ }
+ }
+
+ $this->view->form = $form;
+ }
+
+ public function editAction()
+ {
+ $this->view->headScript()->appendFile('/js/campcaster/playlist/playlist.js','text/javascript');
+
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $pl = Playlist::Recall($pl_sess->id);
+
+ $this->view->playlistcontents = $pl->getContents();
+ return;
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function addItemAction()
+ {
+ $pl_sess = $this->pl_sess;
+ $id = $this->_getParam('id');
+
+ if (!is_null($id)) {
+ if(isset($pl_sess->id)) {
+ $pl = Playlist::Recall($pl_sess->id);
+ $res = $pl->addAudioClip($id);
+
+ if (PEAR::isError($res)) {
+ die('{"jsonrpc" : "2.0", "error" : {"message": ' + $res->getMessage() + '}}');
+ }
+
+ die('{"jsonrpc" : "2.0"}');
+ }
+ die('{"jsonrpc" : "2.0", "error" : {"message": "no open playlist"}}');
+ }
+
+ die('{"jsonrpc" : "2.0", "error" : {"message": "a file is not chosen"}}');
+ }
+
+ public function moveItemAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $oldPos = $this->_getParam('oldPos');
+ $newPos = $this->_getParam('newPos');
+
+ $pl = Playlist::Recall($pl_sess->id);
+
+ $pl->moveAudioClip($oldPos, $newPos);
+
+ $this->view->playlistcontents = $pl->getContents();
+ return;
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function deleteItemAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $positions = $this->_getParam('pos', array());
+
+ $pl = Playlist::Recall($pl_sess->id);
+
+ if (!is_array($positions))
+ $positions = array($positions);
+
+ //so the automatic updating of playlist positioning doesn't affect removal.
+ sort($positions);
+ $positions = array_reverse($positions);
+
+ foreach ($positions as $pos) {
+ $pl->delAudioClip($pos);
+ }
+
+ $this->view->playlistcontents = $pl->getContents();
+ return;
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function setCueAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $pos = $this->_getParam('pos');
+ $cueIn = $this->_getParam('cueIn', null);
+ $cueOut = $this->_getParam('cueOut', null);
+
+ $pl = Playlist::Recall($pl_sess->id);
+
+ $response = $pl->changeClipLength($pos, $cueIn, $cueOut);
+
+ die(json_encode($response));
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function setFadeAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $pos = $this->_getParam('pos');
+ $fadeIn = $this->_getParam('fadeIn', null);
+ $fadeOut = $this->_getParam('fadeOut', null);
+
+ $pl = Playlist::Recall($pl_sess->id);
+
+ $response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut);
+
+ die(json_encode($response));
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function deleteAction()
+ {
+ $id = $this->_getParam('id', null);
+
+ if (!is_null($id)) {
+
+ $this->closePlaylist();
+ Playlist::Delete($id);
+ }
+ }
+
+ public function deleteActiveAction()
+ {
+ $pl_sess = $this->pl_sess;
+
+ if(isset($pl_sess->id)) {
+
+ $pl = Playlist::Recall($pl_sess->id);
+ $this->closePlaylist($pl);
+
+ Playlist::Delete($pl_sess->id);
+
+ unset($pl_sess->id);
+ }
+
+ $this->_helper->redirector('index');
+ }
+
+ public function closePlaylist($pl)
+ {
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $res = $pl->unlock($userInfo->id);
+ return $res;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/controllers/PluploadController.php b/application/controllers/PluploadController.php
new file mode 100644
index 000000000..ffaff33e8
--- /dev/null
+++ b/application/controllers/PluploadController.php
@@ -0,0 +1,179 @@
+hasIdentity())
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('upload', 'json')
+ ->initContext();
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function uploadAction()
+ {
+ // HTTP headers for no cache etc
+ header('Content-type: text/plain; charset=UTF-8');
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: post-check=0, pre-check=0", false);
+ header("Pragma: no-cache");
+
+ // Settings
+ $targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
+ $cleanupTargetDir = false; // Remove old files
+ $maxFileAge = 60 * 60; // Temp file age in seconds
+
+ // 5 minutes execution time
+ @set_time_limit(5 * 60);
+ // usleep(5000);
+
+ // Get parameters
+ $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
+ $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
+ $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
+
+ // Clean the fileName for security reasons
+ //$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
+
+ // Create target dir
+ if (!file_exists($targetDir))
+ @mkdir($targetDir);
+
+ // Remove old temp files
+ if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
+ while (($file = readdir($dir)) !== false) {
+ $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
+
+ // Remove temp files if they are older than the max age
+ if (preg_match('/\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
+ @unlink($filePath);
+ }
+
+ closedir($dir);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
+
+ // Look for the content type header
+ if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
+ $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
+
+ if (isset($_SERVER["CONTENT_TYPE"]))
+ $contentType = $_SERVER["CONTENT_TYPE"];
+
+ if (strpos($contentType, "multipart") !== false) {
+ if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
+ // Open temp file
+ $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
+ if ($out) {
+ // Read binary input stream and append it to temp file
+ $in = fopen($_FILES['file']['tmp_name'], "rb");
+
+ if ($in) {
+ while ($buff = fread($in, 4096))
+ fwrite($out, $buff);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+
+ fclose($out);
+ unlink($_FILES['file']['tmp_name']);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
+ } else {
+ // Open temp file
+ $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
+ if ($out) {
+ // Read binary input stream and append it to temp file
+ $in = fopen("php://input", "rb");
+
+ if ($in) {
+ while ($buff = fread($in, 4096))
+ fwrite($out, $buff);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+
+ fclose($out);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
+ }
+
+ $audio_file = $targetDir . DIRECTORY_SEPARATOR . $fileName;
+
+ $md5 = md5_file($audio_file);
+ $duplicate = StoredFile::RecallByMd5($md5);
+ if ($duplicate) {
+ if (PEAR::isError($duplicate)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
+ }
+ else {
+ $duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
+ }
+ }
+
+ $metadata = camp_get_audio_metadata($audio_file);
+
+ if (PEAR::isError($metadata)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $metadata->getMessage() + '}}');
+ }
+
+ // #2196 no id tag -> use the original filename
+ if (basename($audio_file) == $metadata[UI_MDATA_KEY_TITLE]) {
+ $metadata[UI_MDATA_KEY_TITLE] = basename($audio_file);
+ $metadata[UI_MDATA_KEY_FILENAME] = basename($audio_file);
+ }
+
+ // setMetadataBatch doesnt like these values
+ unset($metadata['audio']);
+ unset($metadata['playtime_seconds']);
+
+ $values = array(
+ "filename" => basename($audio_file),
+ "filepath" => $audio_file,
+ "filetype" => "audioclip",
+ "mime" => $metadata[UI_MDATA_KEY_FORMAT],
+ "md5" => $md5
+ );
+ $storedFile = StoredFile::Insert($values);
+
+ if (PEAR::isError($storedFile)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $storedFile->getMessage() + '}}');
+ }
+
+ $storedFile->setMetadataBatch($metadata);
+
+ // Return JSON-RPC response
+ die('{"jsonrpc" : "2.0", "id" : '.$storedFile->getId().' }');
+ }
+
+ public function pluploadAction()
+ {
+ $view = $this->view;
+
+ $view->headScript()->appendFile('/js/plupload/plupload.full.min.js','text/javascript');
+ $view->headScript()->appendFile('/js/plupload/jquery.plupload.queue.min.js','text/javascript');
+ $view->headScript()->appendFile('/js/campcaster/library/plupload.js','text/javascript');
+
+ $view->headLink()->appendStylesheet('/css/plupload.queue.css');
+ }
+
+
+}
+
+
+
+
+
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
new file mode 100644
index 000000000..e9730cb52
--- /dev/null
+++ b/application/controllers/ScheduleController.php
@@ -0,0 +1,53 @@
+hasIdentity())
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('event-feed', 'json')
+ ->addActionContext('add-show-dialog', 'json')
+ ->initContext();
+ }
+
+ public function indexAction()
+ {
+ $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/campcaster/schedule/schedule.js','text/javascript');
+
+ $this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
+ $this->view->headLink()->appendStylesheet('/css/schedule.css');
+ }
+
+ public function eventFeedAction()
+ {
+ $start = $this->_getParam('start', null);
+ $end = $this->_getParam('end', null);
+ $weekday = $this->_getParam('weekday', null);
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+
+ $show = new Show($userInfo->type);
+ $this->view->events = $show->getFullCalendarEvents($start, $end, $weekday);
+ }
+
+ public function addShowDialogAction()
+ {
+ $user = new User();
+
+ $this->view->hosts = $user->getHosts();
+ }
+
+
+}
+
+
+
+
+
diff --git a/application/controllers/SearchController.php b/application/controllers/SearchController.php
new file mode 100644
index 000000000..4309d4c5b
--- /dev/null
+++ b/application/controllers/SearchController.php
@@ -0,0 +1,77 @@
+hasIdentity())
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('newfield', 'html')
+ ->initContext();
+
+ $this->form = new Application_Form_AdvancedSearch();
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function displayAction()
+ {
+ $this->view->headScript()->appendFile('/js/campcaster/library/advancedsearch.js','text/javascript');
+ $this->view->headLink()->appendStylesheet('/css/library_search.css');
+
+ $this->form = new Application_Form_AdvancedSearch();
+ $form = $this->form;
+
+ // Form has not been submitted - pass to view and return
+ if (!$this->getRequest()->isPost()) {
+ $sub = new Application_Form_AdvancedSearchRow(1);
+ $form->addSubForm($sub, 'row_1');
+ $form->getSubForm('row_1')->removeDecorator('DtDdWrapper');
+
+ $this->view->form = $form;
+ return;
+ }
+
+ // Form has been submitted - run data through preValidation()
+ $form->preValidation($_POST);
+
+ if (!$form->isValid($_POST)) {
+ $this->view->form = $form;
+ return;
+ }
+
+ // Form is valid
+ $this->view->form = $form;
+
+ $info = $form->getValues();
+ $this->view->files = StoredFile::searchFiles($info);
+ }
+
+ public function newfieldAction()
+ {
+ $id = $this->_getParam('id', 1);
+
+ $this->form->addSubForm(new Application_Form_AdvancedSearchRow($id), 'row_'.$id, $id);
+
+ $this->form->getSubForm('row_'.$id)->removeDecorator('DtDdWrapper');
+ $e = $this->form->getSubForm('row_'.$id);
+
+ $this->view->field = $e->__toString();
+ }
+
+}
+
+
+
+
+
diff --git a/application/controllers/plugins/Acl_plugin.php b/application/controllers/plugins/Acl_plugin.php
new file mode 100644
index 000000000..2d7a5dc7d
--- /dev/null
+++ b/application/controllers/plugins/Acl_plugin.php
@@ -0,0 +1,147 @@
+_errorPage = array('module' => 'default',
+ 'controller' => 'error',
+ 'action' => 'denied');
+
+ $this->_roleName = $roleName;
+
+ if (null !== $aclData) {
+ $this->setAcl($aclData);
+ }
+ }
+
+ /**
+ * Sets the ACL object
+ *
+ * @param mixed $aclData
+ * @return void
+ **/
+ public function setAcl(Zend_Acl $aclData)
+ {
+ $this->_acl = $aclData;
+ }
+
+ /**
+ * Returns the ACL object
+ *
+ * @return Zend_Acl
+ **/
+ public function getAcl()
+ {
+ return $this->_acl;
+ }
+
+ /**
+ * Returns the ACL role used
+ *
+ * @return string
+ * @author
+ **/
+ public function getRoleName()
+ {
+ return $this->_roleName;
+ }
+
+ public function setRoleName($type)
+ {
+ $roles = array("A" => "admin", "H" => "host", "G" => "guest");
+ $this->_roleName = $roles[$type];
+ }
+
+ /**
+ * Sets the error page
+ *
+ * @param string $action
+ * @param string $controller
+ * @param string $module
+ * @return void
+ **/
+ public function setErrorPage($action, $controller = 'error', $module = null)
+ {
+ $this->_errorPage = array('module' => $module,
+ 'controller' => $controller,
+ 'action' => $action);
+ }
+
+ /**
+ * Returns the error page
+ *
+ * @return array
+ **/
+ public function getErrorPage()
+ {
+ return $this->_errorPage;
+ }
+
+ /**
+ * Predispatch
+ * Checks if the current user identified by roleName has rights to the requested url (module/controller/action)
+ * If not, it will call denyAccess to be redirected to errorPage
+ *
+ * @return void
+ **/
+ public function preDispatch(Zend_Controller_Request_Abstract $request)
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()){
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $this->setRoleName($userInfo->type);
+ }
+ else {
+ $this->_roleName = "guest";
+ }
+
+ $resourceName = '';
+
+ if ($request->getModuleName() != 'default') {
+ $resourceName .= strtolower($request->getModuleName()) . ':';
+ }
+
+ $resourceName .= strtolower($request->getControllerName());
+
+ /** Check if the controller/action can be accessed by the current user */
+ if (!$this->getAcl()->isAllowed($this->_roleName, $resourceName, $request->getActionName())) {
+ /** Redirect to access denied page */
+ $this->denyAccess();
+ }
+ }
+
+ /**
+ * Deny Access Function
+ * Redirects to errorPage, this can be called from an action using the action helper
+ *
+ * @return void
+ **/
+ public function denyAccess()
+ {
+ $this->_request->setModuleName($this->_errorPage['module']);
+ $this->_request->setControllerName($this->_errorPage['controller']);
+ $this->_request->setActionName($this->_errorPage['action']);
+ }
+}
diff --git a/application/forms/AdvancedSearch.php b/application/forms/AdvancedSearch.php
new file mode 100644
index 000000000..4c915c38e
--- /dev/null
+++ b/application/forms/AdvancedSearch.php
@@ -0,0 +1,51 @@
+addElement('hidden', 'search_next_id', array(
+ 'value' => 2
+ ));
+ $this->getElement('search_next_id')->removeDecorator('Label')->removeDecorator('HtmlTag');
+ }
+
+ public function preValidation(array $data) {
+
+ function findId($name) {
+ $t = explode("_", $name);
+ return $t[1];
+ }
+
+ // array_filter callback
+ function findFields($field) {
+ return strpos($field, 'row') !== false;
+ }
+
+ $fields = array_filter(array_keys($data), 'findFields');
+
+ foreach ($fields as $field) {
+ // use id to set new order
+ $id = findId($field);
+ $this->addNewField($data, $id);
+ }
+ }
+
+ public function addNewField($data, $id) {
+
+ $sub = new Application_Form_AdvancedSearchRow($id);
+
+ $values = array("metadata_".$id => $data["row_".$id]["metadata_".$id],
+ "match_".$id => $data["row_".$id]["match_".$id],
+ "search_".$id => $data["row_".$id]["search_".$id]);
+
+ $sub->setDefaults($values);
+
+ $this->addSubForm($sub, 'row_'.$id, $id);
+ $this->getSubForm('row_'.$id)->removeDecorator('DtDdWrapper');
+ }
+
+
+}
+
diff --git a/application/forms/AdvancedSearchRow.php b/application/forms/AdvancedSearchRow.php
new file mode 100644
index 000000000..a647e7656
--- /dev/null
+++ b/application/forms/AdvancedSearchRow.php
@@ -0,0 +1,81 @@
+_rowid = $id;
+ parent::__construct();
+ }
+
+ public function init()
+ {
+ $id = $this->_rowid;
+
+ $this->addElement(
+ 'select',
+ 'metadata_'.$id,
+ array(
+ 'required' => true,
+ 'multiOptions' => array(
+ "dc:title" => "Title",
+ "dc:format" => "Format",
+ "dc:creator" => "Artist/Creator",
+ "dc:source" => "Album",
+ "ls:bitrate" => "Bitrate",
+ "ls:samplerate" => "Samplerate",
+ "dcterms:extent" => "Length",
+ "dc:description" => "Comments",
+ "dc:type" => "Genre",
+ "ls:channels" => "channels",
+ "ls:year" => "Year",
+ "ls:track_num" => "track_number",
+ "ls:mood" => "mood",
+ "ls:bpm" => "BPM",
+ "ls:rating" => "rating",
+ "ls:encoded_by" => "encoded_by",
+ "dc:publisher" => "label",
+ "ls:composer" => "Composer",
+ "ls:encoder" => "Encoder",
+ "ls:lyrics" => "lyrics",
+ "ls:orchestra" => "orchestra",
+ "ls:conductor" => "conductor",
+ "ls:lyricist" => "lyricist",
+ "ls:originallyricist" => "original_lyricist",
+ "ls:isrcnumber" => "isrc_number",
+ "dc:language" => "Language",
+ ),
+ )
+ );
+ $this->getElement('metadata_'.$id)->removeDecorator('Label')->removeDecorator('HtmlTag');
+
+ $this->addElement(
+ 'select',
+ 'match_'.$id,
+ array(
+ 'required' => true,
+ 'multiOptions' => array(
+ "0" => "partial",
+ "1" => "=",
+ "2" => "<",
+ "3" => "<=",
+ "4" => ">",
+ "5" => ">=",
+ "6" => "!=",
+ ),
+ )
+ );
+ $this->getElement('match_'.$id)->removeDecorator('Label')->removeDecorator('HtmlTag');
+
+ $this->addElement('text', 'search_'.$id, array(
+ 'required' => true,
+ ));
+ $this->getElement('search_'.$id)->removeDecorator('Label')->removeDecorator('HtmlTag');
+ }
+
+
+}
+
diff --git a/application/forms/EditAudioMD.php b/application/forms/EditAudioMD.php
new file mode 100644
index 000000000..4f9323a56
--- /dev/null
+++ b/application/forms/EditAudioMD.php
@@ -0,0 +1,13 @@
+setMethod('post');
+
+ // Add username element
+ $this->addElement('text', 'username', array(
+ 'label' => 'Username:',
+ 'required' => true,
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ 'NotEmpty',
+ )
+ ));
+
+ // Add password element
+ $this->addElement('password', 'password', array(
+ 'label' => 'Password:',
+ 'required' => true,
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ 'NotEmpty',
+ )
+ ));
+
+ // Add the submit button
+ $this->addElement('submit', 'submit', array(
+ 'ignore' => true,
+ 'label' => 'Login',
+ ));
+
+ }
+
+
+}
+
diff --git a/application/forms/PlaylistMetadata.php b/application/forms/PlaylistMetadata.php
new file mode 100644
index 000000000..fb15ee544
--- /dev/null
+++ b/application/forms/PlaylistMetadata.php
@@ -0,0 +1,36 @@
+setMethod('post');
+
+ // Add username element
+ $this->addElement('text', 'title', array(
+ 'label' => 'Title:',
+ 'required' => true,
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ 'NotEmpty',
+ )
+ ));
+
+ // Add the comment element
+ $this->addElement('textarea', 'description', array(
+ 'label' => 'Description:',
+ 'required' => false,
+ ));
+
+ // Add the submit button
+ $this->addElement('submit', 'submit', array(
+ 'ignore' => true,
+ 'label' => 'Submit',
+ ));
+ }
+
+
+}
+
diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml
new file mode 100644
index 000000000..b85faa6b4
--- /dev/null
+++ b/application/layouts/scripts/layout.phtml
@@ -0,0 +1,17 @@
+
+doctype() ?>
+
+
\ncorrect:\n{$test_correct}\n". + "dump:\n{$test_dump}\n\n"); + } + } // fn test + +} // class Alib +?> \ No newline at end of file diff --git a/application/models/Backup.php b/application/models/Backup.php new file mode 100755 index 000000000..211faa362 --- /dev/null +++ b/application/models/Backup.php @@ -0,0 +1,487 @@ +gb =& $gb; + $this->token = null; + $this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log'; + $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n"); + } + + + /** + * Open a backup + * Create a backup file (tarball) + * + * @param string $sessid + * @param array $criteria + * struct - see search criteria + * @return array + * hasharray with field: + * token string: backup token + */ + public function openBackup($sessid, $criteria='') + { + if ($this->loglevel=='debug') { + $this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n"); + } + $this->sessid = $sessid; + $this->criteria = $criteria; + + // get ids (and real filenames) which files match with criteria + $srch = $this->gb->localSearch($this->criteria,$this->sessid); + if (PEAR::isError($srch)) { + return $srch; + } + $this->setIDs($srch); + + // get real filenames + if (is_array($this->ids)) { + $this->setFilenames(); + + $this->setEnviroment(true); + + // write a status file + file_put_contents($this->statusFile, 'working'); + + // save the metafile to tmpdir + $hostname = trim(`hostname`); + $ctime = time(); + $ctime_f = date("Ymd-H:i:s"); + file_put_contents("{$this->tmpDirMeta}/storage.xml", + "\n". + "
+ * Format of search/browse results: hash, with following structure:
+ *
\n"; + print_r($va); + } + + + /** + * deleteFiles + * + * @return void + */ +// private function deleteFiles() +// { +// global $CC_CONFIG, $CC_DBC; +// $ids = $CC_DBC->getAll("SELECT id FROM ".$CC_CONFIG['filesTable']); +// if (is_array($ids)) { +// foreach ($ids as $i => $item) { +// $f = StoredFile::Recall($item['id']); +// $f->delete(); +// } +// } +// } + + + /** + * Aux logging for debug + * + * @param string $msg - log message + */ + public function debugLog($msg) + { + global $CC_CONFIG, $CC_DBC; + $fp = fopen($CC_CONFIG['storageDir']."/log", "a") or die("Can't write to log\n"); + fputs($fp, date("H:i:s").">$msg<\n"); + fclose($fp); + } + +} // class BasicStor +?> \ No newline at end of file diff --git a/application/models/GreenBox.php b/application/models/GreenBox.php new file mode 100644 index 000000000..a46ffa752 --- /dev/null +++ b/application/models/GreenBox.php @@ -0,0 +1,1726 @@ +"; +} +require_once("BasicStor.php"); +if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) { + echo __FILE__.':line '.__LINE__.": Loaded BasicStor
"; +} +require_once("Playlist.php"); +require_once("Renderer.php"); +require_once('Prefs.php'); +require_once("Backup.php"); +require_once('Restore.php'); +require_once("Transport.php"); + +/** + * GreenBox class + * + * File storage module. + * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class GreenBox extends BasicStor { + + /* ====================================================== storage methods */ + + /** + * Store new file in the storage + * + * @param string $fileName + * The name for the new file. + * @param string $mediaFileLP + * Local path of the media file + * @param string $mdataFileLP + * Local path of the metadata file + * @param string $sessid + * Session id + * @param string $gunid + * Global unique id + * @param string $ftype + * Internal file type + * @return int + * ID of the StoredFile that was created. + */ + public function putFile($p_values, $p_sessionId='') + { + if (($res = BasicStor::Authorize('write', null, $p_sessionId)) !== TRUE) { + return $res; + } + $storedFile = StoredFile::Insert($p_values); + return $storedFile; + } // fn putFile + + + /** + * Store new webstream + * + * @param string $fileName + * Name for new file + * @param string $mdataFileLP + * Local path of metadata file + * @param string $sessid + * Session id + * @param string $gunid + * Global unique id + * @param string $url + * Webstream url + * @return int + * @exception PEAR::error + */ + public function storeWebstream($fileName, $mdataFileLP, $sessid='', + $gunid=NULL, $url) + { + if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) { + return $res; + } + if (!file_exists($mdataFileLP)) { + $mdataFileLP = dirname(__FILE__).'/emptyWebstream.xml'; + } + $values = array( + "filename" => $fileName, + "metadata" => $mdataFileLP, + "gunid" => $gunid, + "filetype" => "webstream" + ); + $storedFile = StoredFile::Insert($values); + if (PEAR::isError($storedFile)) { + return $storedFile; + } + $r = $storedFile->setMetadataValue('ls:url', $url); + if (PEAR::isError($r)) { + return $r; + } + return $oid; + } // fn storeWebstream + + + /** + * Access stored file - increase access counter + * + * @param int $id + * virt.file's local id + * @param string $sessid + * session id + * @return string access token + */ +// function accessFile($id, $sessid='') +// { +// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { +// return $res; +// } +// $gunid = BasicStor::GunidFromId($id); +// $r = BasicStor::bsAccess(NULL, '', $gunid, 'access'); +// if (PEAR::isError($r)) { +// return $r; +// } +// $token = $r['token']; +// return $token; +// } // fn accessFile + + + /** + * Release stored file - decrease access counter + * + * @param string $token + * access token + * @param string $sessid + * session id + * @return boolean + */ +// function releaseFile($token, $sessid='') +// { +// $r = BasicStor::bsRelease($token, 'access'); +// if (PEAR::isError($r)) { +// return $r; +// } +// return FALSE; +// } // fn releaseFile + + + /** + * Analyze media file for internal metadata information + * + * @param int $id + * Virtual file's local id + * @param string $sessid + * Session id + * @return array + */ +// public function analyzeFile($id, $sessid='') +// { +// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { +// return $res; +// } +// return $this->bsAnalyzeFile($id); +// } + + + /** + * Rename file + * + * @param int $id + * Virtual file's local id + * @param string $newName + * @param string $sessid + * Session id + * @return boolean|PEAR_Error + */ +// public function renameFile($id, $newName, $sessid='') +// { +// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { +// return $res; +// } +// return $this->bsRenameFile($id, $newName); +// } + + + /** + * Replace file. Doesn't change filetype! + * + * @param int $id + * virt.file's local id + * @param string $mediaFileLP + * local path of media file + * @param string $mdataFileLP + * local path of metadata file + * @param string $sessid + * session id + * @return TRUE|PEAR_Error + */ +// public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='') +// { +// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { +// return $res; +// } +// return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP); +// } + + + /** + * Delete file + * + * @param int $id + * local id + * @param int $sessid + * @param boolean $forced + * if true don't use trash -- now ignored + * @return true|PEAR_Error + */ + public function deleteFile($id, $sessid='', $forced=FALSE) + { + if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { + return $res; + } + $f = StoredFile::Recall($id); + return $f->delete(true); + } + + + /* ------------------------------------------------------------- metadata */ + + /** + * Replace metadata with new XML file or string + * + * @param int $id + * Virtual file's local id + * @param string $mdata + * XML string or local path of metadata XML file + * @param string $mdataLoc + * metadata location: 'file'|'string' + * @param string $sessid + * session id + * @return boolean|PEAR_Error + */ +// public function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='') +// { +// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { +// return $res; +// } +// return $this->bsReplaceMetadata($id, $mdata, $mdataLoc); +// } // fn replaceMetadata + + + /** + * Get metadata XML tree as string + * + * @param int $id + * Virtual file's local id + * @param string $sessid + * session id + * @return string|PEAR_Error + * @todo rename this function to "getMetadata" + */ + public function getMetadata($id, $sessid='') + { + if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { + return $res; + } + $f = StoredFile::Recall($id); + return $f->getMetadata(); + } + + + /** + * Return metadata as hierarchical PHP hash-array + * + * If xml:lang attribute is specified in metadata category, + * array of metadata values indexed by xml:lang values + * is presented instead of one plain metadata value. + * + * @param int $id + * local object id + * @param string $sessid + * session ID + * @return array + */ + public function getMetadataArray($id, $sessid) + { + if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { + return $res; + } + $storedFile = StoredFile::Recall($id); + if (is_null($storedFile) || PEAR::isError($storedFile)) { + return $storedFile; + } + return $storedFile->md; + +// $arr = $storedFile->md->genPhpArray(); + $md = FALSE; + foreach ($arr['children'] as $i=>$a) { + if ($a['elementname'] == 'metadata'){ + $md = $arr['children'][$i]; + break; + } + } + if ($md === FALSE) { + return PEAR::raiseError( + "GreenBox::getMetadataArray: no metadata container found" + ); + } + $res = array(); + foreach ($md['children'] as $el) { + $lang = isset($el['attrs']['xml:lang']) ? $el['attrs']['xml:lang'] : ""; + $category = $el['elementname']; + if ($lang == "") { + $res[$category] = $el['content']; + } else { + $res[$category][$lang] = $el['content']; + } + } + return $res; + } + + + /** + * Get metadata element value + * + * @param int $id + * Virtual file's local id + * @param string $category + * metadata element name + * @param string $sessid + * session id + * @param string $lang + * xml:lang value for select language version + * @param string $deflang + * xml:lang for default language + * @return array of matching records as hash with fields: + *
";var_dump($data); + $playlists = array(); + + if (is_array($data) && count($data) > 0) + { + foreach ($data as $dx) + { + // Is this the first item in the playlist? + $start = $dx['start']; + // chop off subseconds + $start = substr($start, 0, 19); + + // Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss" + $pkey = Schedule::CcTimeToPypoTime($start); + $timestamp = strtotime($start); + $playlists[$pkey]['source'] = "PLAYLIST"; + $playlists[$pkey]['x_ident'] = $dx["playlist_id"]; + $playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive + $playlists[$pkey]['timestamp'] = $timestamp; + $playlists[$pkey]['duration'] = $dx['clip_length']; + $playlists[$pkey]['played'] = '0'; + $playlists[$pkey]['schedule_id'] = $dx['group_id']; + } + } + + foreach ($playlists as &$playlist) + { + $scheduleGroup = new ScheduleGroup($playlist["schedule_id"]); + $items = $scheduleGroup->getItems(); + $medias = array(); + $playlist['subtype'] = '1'; + foreach ($items as $item) + { + $storedFile = StoredFile::Recall($item["file_id"]); + $uri = $storedFile->getFileUrl(); + $medias[] = array( + 'id' => $storedFile->getGunid(), //$item["file_id"], + 'uri' => $uri, + 'fade_in' => $item["fade_in"], + 'fade_out' => $item["fade_out"], + 'fade_cross' => 0, + 'cue_in' => $item["cue_in"], + 'cue_out' => $item["cue_out"], + ); + } + $playlist['medias'] = $medias; + } + + $result = array(); + $result['status'] = array('range' => $range_dt, 'version' => 0.2); + $result['playlists'] = $playlists; + $result['check'] = 1; + + print json_encode($result); + } + +} + +?> \ No newline at end of file diff --git a/application/models/Shows.php b/application/models/Shows.php new file mode 100644 index 000000000..9d333fd52 --- /dev/null +++ b/application/models/Shows.php @@ -0,0 +1,123 @@ +_userRole = $userType; + + } + + private function makeFullCalendarEvent($show, $date, $options=array()) { + + $start = $date."T".$show["start_time"]; + $end = $date."T".$show["end_time"]; + + $event = array( + "id" => $show["show_id"], + "title" => $show["name"], + "start" => $start, + "end" => $end, + "allDay" => false, + "description" => $show["description"] + ); + + foreach($options as $key=>$value) { + $event[$key] = $value; + } + + if($this->_userRole === "A") { + $event["editable"] = true; + } + + return $event; + } + + public function addShow() { + + $sql = 'INSERT INTO cc_show + ("name", "first_show", "last_show", "start_time", "end_time", + "repeats", "day", "description", "show_id") + VALUES ()'; + + } + + public function getShows($start=NULL, $end=NULL, $weekday=NULL) { + global $CC_DBC; + + $sql; + + $sql_gen = "SELECT * FROM cc_show"; + $sql = $sql_gen; + + if(!is_null($start) && !is_null($end)) { + $sql_range = "(first_show < '{$start}' AND last_show IS NULL) + OR (first_show >= '{$start}' AND first_show < '{$end}') + OR (last_show >= '{$start}' AND last_show < '{$end}') + OR (first_show < '{$start}' AND last_show >= '{$end}')"; + + $sql = $sql_gen ." WHERE ". $sql_range; + } + if(!is_null($weekday)){ + $sql_day = "day = {$weekday}"; + + $sql = $sql_gen ." WHERE (". $sql_day ." AND (". $sql_range ."))"; + } + + return $CC_DBC->GetAll($sql); + } + + public function getFullCalendarEvents($start, $end, $weekday=NULL) { + global $CC_DBC; + $shows = array(); + + $res = $this->getShows($start, $end, $weekday); + + foreach($res as $row) { + + if(!is_null($start)) { + + $timeDiff = "SELECT date '{$start}' - date '{$row["first_show"]}' as diff"; + $diff = $CC_DBC->GetOne($timeDiff); + + if($diff > 0) { + + $add = ($diff % 7 === 0) ? $diff : $diff + (7 - $diff % 7); + + $new = "SELECT date '{$row["first_show"]}' + integer '{$add}'"; + $newDate = $CC_DBC->GetOne($new); + } + else { + $newDate = $row["first_show"]; + } + + $shows[] = $this->makeFullCalendarEvent($row, $newDate); + + $end_epoch = strtotime($end); + + if($row["repeats"]) { + + while(true) { + + $diff = "SELECT date '{$newDate}' + integer '7'"; + $repeatDate = $CC_DBC->GetOne($diff); + $repeat_epoch = strtotime($repeatDate); + + if ($repeat_epoch < $end_epoch ) { + $shows[] = $this->makeFullCalendarEvent($row, $repeatDate); + } + else { + break; + } + + $newDate = $repeatDate; + } + } + } + } + + return $shows; + } +} diff --git a/application/models/SmilPlaylist.php b/application/models/SmilPlaylist.php new file mode 100644 index 000000000..dc4ca7f78 --- /dev/null +++ b/application/models/SmilPlaylist.php @@ -0,0 +1,313 @@ + +define('INDCH', ' '); + +require_once("XmlParser.php"); + +/** + * SmilPlaylist class + * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class SmilPlaylist { + + /** + * Parse SMIL file or string + * + * @param string $data + * local path to SMIL file or SMIL string + * @param string $loc + * location: 'file'|'string' + * @return array + * reference, parse result tree (or PEAR::error) + */ + private static function &parse($data='', $loc='file') + { + return XmlParser::parse($data, $loc); + } + + + /** + * Import SMIL file to storage + * + * @param GreenBox $gb + * reference to GreenBox object + * @param string $aPath + * absolute path part of imported file (e.g. /home/user/campcaster) + * @param string $rPath + * relative path/filename part of imported file + * (e.g. playlists/playlist_1.smil) + * @param array $gunids + * hash relation from filenames to gunids + * @param string $plid + * playlist gunid + * @param int $subjid + * local subject (user) id (id of user doing the import) + * @return Playlist + */ + public static function &import(&$gb, $aPath, $rPath, &$gunids, $plid, $subjid=NULL) + { + $parr = compact('subjid', 'aPath', 'plid', 'rPath'); + $path = realpath("$aPath/$rPath"); + if (FALSE === $path) { + return PEAR::raiseError( + "SmilPlaylist::import: file doesn't exist ($aPath/$rPath)" + ); + } + $lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr); + if (PEAR::isError($lspl)) { + return $lspl; + } + require_once("Playlist.php"); + $pl =& Playlist::create($gb, $plid, "imported_SMIL"); + if (PEAR::isError($pl)) { + return $pl; + } + $r = $pl->lock($gb, $subjid); + if (PEAR::isError($r)) { + return $r; + } + $r = $pl->setMetadata($lspl, 'string', 'playlist'); + if (PEAR::isError($r)) { + return $r; + } + $r = $pl->unlock($gb); + if (PEAR::isError($r)) { + return $r; + } + return $pl; + } + + + /** + * Import SMIL file to storage. + * + * @param GreenBox $gb + * @param string $data + * local path to SMIL file + * @param hasharray $gunids + * hash relation from filenames to gunids + * @param array $parr + * array of subjid, aPath, plid, rPath + * @return string + * XML of playlist in Campcaster playlist format + */ + public static function convert2lspl(&$gb, $data, &$gunids, $parr) + { + extract($parr); + $tree = SmilPlaylist::parse($data); + if (PEAR::isError($tree)) { + return $tree; + } + if ($tree->name != 'smil') { + return PEAR::raiseError("SmilPlaylist::parse: smil tag expected"); + } + if (isset($tree->children[1])) { + return PEAR::raiseError(sprintf( + "SmilPlaylist::parse: unexpected tag %s in tag smil", + $tree->children[1]->name + )); + } + $res = SmilPlaylistBodyElement::convert2lspl( + $gb, $tree->children[0], &$gunids, $parr); + return $res; + } + +} // SmilPlaylist + + +/** + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class SmilPlaylistBodyElement { + + public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') + { + extract($parr); + $ind2 = $ind.INDCH; + if ($tree->name != 'body') { + return PEAR::raiseError("SmilPlaylist::parse: body tag expected"); + } + if (isset($tree->children[1])) { + return PEAR::raiseError(sprintf( + "SmilPlaylist::parse: unexpected tag %s in tag body", + $tree->children[1]->name + )); + } + $res = SmilPlaylistParElement::convert2lspl( + $gb, $tree->children[0], &$gunids, $parr, $ind2); + if (PEAR::isError($res)) { + return $res; + } + $title = basename($rPath); + $playlength = '0'; + $res = "$ind\n". + "$ind+ * @package Campcaster + * @subpackage StorageServer.Cron + */ +class Cron { + /** + * @var Crontab + */ + public $ct; + + /** + * @var array This array created with getCommand() function + */ + private $params; + + /** + * @var string available values: read | write + */ + private $ctAccess = 'read'; + + private $lockfile; + private $cronfile; + private $paramdir; + private $cronUserName; + + /** + * Constructor + */ + function Cron() { + global $CC_CONFIG; + $this->lockfile = $CC_CONFIG['lockfile']; + $this->cronfile = $CC_CONFIG['cronfile']; + $this->paramdir = $CC_CONFIG['paramdir']; + $this->cronUserName = $CC_CONFIG['cronUserName']; + } + + + /* ==================================================== Cronjob functions */ + /** + * Add a cronjob to the crontab + * + * @access public + * @param string $m minute + * @param string $h hour + * @param string $dom day of month + * @param string $mo month + * @param string $dow day of week + * @param string $className name of class, which's execute() is called by croncall.php + * @param string $params the parameter(s) + * @return bool true if success else PEAR error. + */ + function addCronJob($m, $h, $dom, $mo, $dow, $className, $params) + { + if ($this->ctAccess == 'write') { + $this->ct->addCron($m, $h, $dom, $mo, $dow, + $this->getCommand($className, $params)); + return true; + } else { + return PEAR::raiseError('CronJob::addCronJob : '. + 'The crontab is not writable'); + } + } + + /** + * This function return with the active cronjobs + * + * @access public + * @return array array of cronjob struct + */ + function listCronJob() + { + return $this->ct->getByType(CRON_CMD); + } + + /** + * Remove a cronjob. + * + * @access public + * @param int $index index of the cronjobs' array. + * @return bool true if success else PEAR error. + */ + function removeCronJob($index) + { + if ($this->ctAccess == 'write') { + $this->crontab->delEntry($index); + return true; + } else { + return PEAR::raiseError('CronJob::removeCronJob : '. + 'The crontab is not writable'); + } + } + + /* ==================================================== Crontab functions */ + /** + * Open the crontab + * + * @access public + * @param string $access only for listing 'read', for add and delete 'write' + * @return string sucessed access - available values read | write + */ + function openCrontab($access = 'read') + { + $access = strtolower($access); + $this->ct = new Crontab($this->cronUserName); + if ($access == 'write' && + $this->isCrontabWritable() && + $this->lockCrontab()) { + $this->ctAccess = $access; + } else { + $this->ctAccess = 'read'; + } + return $this->ctAccess; + } + + /** + * Close the crontab + * + * @access public + * @return bool true if everything is ok, false is the lock file can't delete + */ + function closeCrontab() + { + if ($this->ctAccess == 'write') { + $this->ct->writeCrontab(); + } + return $this->ctAccess == 'write' ? $this->unlockCrontab() : true; + } + + /** + * Check the crontab is writable + * + * @access private + * @return bool + */ + function isCrontabWritable() + { + return !is_file($this->lockfile); + } + + /** + * Try to lock the crontab + * + * @access private + * @return bool true if the locking is success + */ + function lockCrontab() + { + return @touch($this->lockfile); + } + + /** + * Try to unlock the crontab + * + * @access private + * @return bool true if the unlocking is success + */ + function unlockCrontab() + { + return unlink($this->lockfile); + } + + /** + * If the crontab opened with read access. This function force set + * the access to write. + * + * @access public + * @return bool true if the setting is success + */ + function forceWriteable() + { + if ($this->isCrontabWritable() && $this->lockCrontab()) { + $this->ctAccess = 'write'; + return true; + } + return false; + } + + /* ======================================================= Misc functions */ + /** + * Get the shell command for the cronjob + * + * @param string $className name of the class what is called by croncall.php + * @param mixed $params with this parameter could be called the execute() of class + * @return string shell command + */ + function getCommand($className, $params) + { + $this->params = array ( + 'class' => $className, + 'params' => $params + ); + return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"'; + } +} +?> \ No newline at end of file diff --git a/application/models/cron/CronJob.php b/application/models/cron/CronJob.php new file mode 100755 index 000000000..bcd1c82d6 --- /dev/null +++ b/application/models/cron/CronJob.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/application/models/cron/Crontab.php b/application/models/cron/Crontab.php new file mode 100755 index 000000000..92b40ac38 --- /dev/null +++ b/application/models/cron/Crontab.php @@ -0,0 +1,284 @@ + "value" + * or a line can be a comment (string beginning with #) + * or it can be a special command (beginning with an @) + * @var array + */ + private $crontabs; + + /** + * The user for whom the crontab will be manipulated + * @var string + */ + private $user; + + /** + * Lists the type of line of each line in $crontabs. + * can be: any of the CRON_* constants. + * so $linetype[5] is the type of $crontabs[5]. + * @var string + */ + private $linetypes; + + // }}} + + /** + * Constructor + * + * Initialises $this->crontabs + * + * @param string $user the user for whom the crontab will be manipulated + */ + function Crontab($user) + { + $this->user = $user; + $this->readCrontab(); + } + + /** + * This reads the crontab of $this->user and parses it in $this->crontabs + * + */ + function readCrontab() + { + // return code is 0 or 1 if crontab was empty, elsewhere stop here + $cmd = "crontab -u {$this->user} -l"; + @exec("crontab -u {$this->user} -l", $crons, $return); + if ($return > 1) { + return PEAR::raiseError("*** Can't read crontab ***\n". + " Set crontab manually!\n"); + } + + foreach ($crons as $line) + { + $line = trim($line); // discarding all prepending spaces and tabs + + // empty lines.. + if (!$line) { + $this->crontabs[] = "empty line"; + $this->linetypes[] = CRON_EMPTY; + continue; + } + + // checking if this is a comment + if ($line[0] == "#") { + $this->crontabs[] = trim($line); + $this->linetypes[] = CRON_COMMENT; + continue; + } + + // Checking if this is an assignment + if (ereg("(.*)=(.*)", $line, $assign)) { + $this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]); + $this->linetypes[] = CRON_ASSIGN; + continue; + } + + // Checking if this is a special @-entry. check man 5 crontab for more info + if ($line[0] == '@') { + $this->crontabs[] = split("[ \t]", $line, 2); + $this->linetypes[] = CRON_SPECIAL; + continue; + } + + // It's a regular crontab-entry + $ct = split("[ \t]", $line, 6); + $this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5]); + } + } + + /** + * Writes the current crontab + */ + function writeCrontab() + { + global $DEBUG, $PATH; + + if (empty($this->linetypes)) { + return; + } + $filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron")); + $file = fopen($filename, "w"); + + foreach($this->linetypes as $i => $line) { + switch ($this->linetypes[$i]) { + case CRON_COMMENT: + $line = $this->crontabs[$i]; + break; + case CRON_ASSIGN: + $line = $this->crontabs[$i][name]." = ".$this->crontabs[$i][value]; + break; + case CRON_CMD: + $line = implode(" ", $this->crontabs[$i]); + break; + case CRON_SPECIAL: + $line = implode(" ", $this->crontabs[$i]); + break; + case CRON_EMPTY: + $line = "\n"; // an empty line in the crontab-file + break; + default: + unset($line); + echo "Something very weird is going on. This line ($i) has an unknown type.\n"; + break; + } + + // echo "line $i : $line\n"; + + if ($line) { + $r = @fwrite($file, $line."\n"); + if($r === FALSE) { + return PEAR::raiseError("*** Can't write crontab ***\n". + " Set crontab manually!\n"); + } + } + } + fclose($file); + + if ($DEBUG) { + echo "DEBUGMODE: not updating crontab. writing to $filename instead.\n"; + } else { + exec("crontab -u {$this->user} $filename", $returnar, $return); + if ($return != 0) { + echo "Error running crontab ($return). $filename not deleted\n"; + } else { + unlink($filename); + } + } + } + + + /** + * Add a item of type CRON_CMD to the end of $this->crontabs + * + * @param string $m + * minute + * @param string $h + * hour + * @param string $dom + * day of month + * @param string $mo + * month + * @param string $dow + * day of week + * @param string $cmd + * command + * + */ + function addCron($m, $h, $dom, $mo, $dow, $cmd) + { + $this->crontabs[] = array ("minute" => $m, "hour" => $h, "dayofmonth" => $dom, "month" => $mo, "dayofweek" => $dow, "command" => $cmd); + $this->linetypes[] = CRON_CMD; + } + + + /** + * Add a comment to the cron to the end of $this->crontabs + * + * @param string $comment + */ + function addComment($comment) + { + $this->crontabs[] = "# $comment\n"; + $this->linetypes[] = CRON_COMMENT; + } + + + /** + * Add a special command (check man 5 crontab for more information) + * + * @param string $sdate special date + * string meaning + * ------ ------- + * @reboot Run once, at startup. + * @yearly Run once a year, "0 0 1 1 *". + * @annually (same as @yearly) + * @monthly Run once a month, "0 0 1 * *". + * @weekly Run once a week, "0 0 * * 0". + * @daily Run once a day, "0 0 * * *". + * @midnight (same as @daily) + * @hourly Run once an hour, "0 * * * *". + * @param string $cmd command + */ + function addSpecial($sdate, $cmd) + { + $this->crontabs[] = array ("special" => $sdate, "command" => $cmd); + $this->linetypes[] = CRON_SPECIAL; + } + + + /** + * Add an assignment (name = value) + * + * @param string $name + * @param string $value + */ + function addAssign($name, $value) + { + $this->crontabs[] = array ("name" => $name, "value" => $value); + $this->linetypes[] = CRON_ASSIGN; + } + + + /** + * Delete a line from the arrays. + * + * @param int $index the index in $this->crontabs + */ + function delEntry($index) + { + unset ($this->crontabs[$index]); + unset ($this->linetypes[$index]); + } + + + /** + * Get all the lines of a certain type in an array + * + * @param string $type + */ + function getByType($type) + { + if ($type < CRON_COMMENT || $type > CRON_EMPTY) + { + trigger_error("Wrong type: $type", E_USER_WARNING); + return 0; + } + + $returnar = array (); + for ($i = 0; $i < count($this->linetypes); $i ++) + if ($this->linetypes[$i] == $type) + $returnar[] = $this->crontabs[$i]; + + return $returnar; + } +} +?> \ No newline at end of file diff --git a/application/models/cron/croncall.php b/application/models/cron/croncall.php new file mode 100755 index 000000000..bae49815b --- /dev/null +++ b/application/models/cron/croncall.php @@ -0,0 +1,9 @@ +#!/usr/bin/php +execute($p['params']); +exit(0); +?> \ No newline at end of file diff --git a/application/models/cron/transportCron.php b/application/models/cron/transportCron.php new file mode 100755 index 000000000..63845ee9d --- /dev/null +++ b/application/models/cron/transportCron.php @@ -0,0 +1,21 @@ +#!/usr/bin/php +setErrorHandling(PEAR_ERROR_RETURN); +$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); + +$gb = new LocStor(); +$tr = new Transport($gb); + +$r = $tr->cronMain(); +if (!$r) { + exit(1); +} + +exit(0); +?> \ No newline at end of file diff --git a/application/models/cron/transportCronJob.php b/application/models/cron/transportCronJob.php new file mode 100755 index 000000000..795dd659a --- /dev/null +++ b/application/models/cron/transportCronJob.php @@ -0,0 +1,42 @@ +#!/usr/bin/php +setErrorHandling(PEAR_ERROR_RETURN); +$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); + +$gb = new LocStor(); +$tr = new Transport($gb); + +$pid = getmypid(); +list(, $trtok) = $_SERVER['argv']; +if (TR_LOG_LEVEL > 1) { + $tr->trLog("transportCronJob($pid) start ($trtok)"); +} + +// 4-pass on job: +$cnt = 4; +for ($i = 0; $i < $cnt; $i++, sleep(1)) { + // run the action: + $r = $tr->cronCallMethod($trtok); + if (PEAR::isError($r)) { + $tr->trLogPear("transportCronJob($pid): ($trtok): ", $r); + } else { +# $tr->trLog("X transportCronJob: ".var_export($r, TRUE)); + if ($r !== TRUE) { + $tr->trLog("transportCronJob($pid): ($trtok): nonTRUE returned"); + } + } + #if(!$r) exit(1); + #sleep(2); +} + +if (TR_LOG_LEVEL>1) { + $tr->trLog("transportCronJob($pid) end ($trtok)"); +} +exit(0); +?> \ No newline at end of file diff --git a/application/models/genres.xml b/application/models/genres.xml new file mode 100644 index 000000000..9afb92275 --- /dev/null +++ b/application/models/genres.xml @@ -0,0 +1,136 @@ + + + + + + +]> +\n". + "$ind2 \n"; + return $res; + } + +} // class SmilPlaylistBodyElement + + +/** + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class SmilPlaylistParElement { + + public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') + { + extract($parr); + if ($tree->name != 'par') { + return PEAR::raiseError("SmilPlaylist::parse: par tag expected"); + } + $res = ''; + foreach ($tree->children as $i => $ch) { + $ch =& $tree->children[$i]; + $r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH); + if (PEAR::isError($r)) { + return $r; + } + $res .= $r; + } + return $res; + } +} + + +/** + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class SmilPlaylistAudioElement { + public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') + { + extract($parr); + $uri = $tree->attrs['src']->val; + $gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL); + $ind2 = $ind.INDCH; + if ($tree->name != 'audio') { + return PEAR::raiseError("SmilPlaylist::parse: audio tag expected"); + } + if (isset($tree->children[2])) { + return PEAR::raiseError(sprintf( + "SmilPlaylist::parse: unexpected tag %s in tag audio", + $tree->children[2]->name + )); + } + $res = ''; $fadeIn = 0; $fadeOut = 0; + foreach ($tree->children as $i => $ch) { + $ch =& $tree->children[$i]; + $r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2); + if (PEAR::isError($r)) { + return $r; + } + switch ($r['type']) { + case "fadeIn": $fadeIn = $r['val']; break; + case "fadeOut": $fadeOut = $r['val']; break; + } + } + if ($fadeIn > 0 || $fadeOut > 0) { + $fiGunid = StoredFile::CreateGunid(); + $fadeIn = Playlist::secondsToPlaylistTime($fadeIn); + $fadeOut = Playlist::secondsToPlaylistTime($fadeOut); + $fInfo = "$ind2\n". + "$res". + "$ind \n"; + } else { + $fInfo = ''; + } + $plElGunid = StoredFile::CreateGunid(); + $acGunid = $gunid; + $type = 'audioClip'; + if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { + switch (strtolower($ext = $va[1])) { + case "lspl": + case "xml": + case "smil": + case "m3u": + $type = 'playlist'; + $acId = $gb->bsImportPlaylistRaw($gunid, + $aPath, $uri, $ext, $gunids, $subjid); + if (PEAR::isError($acId)) { + return $r; + } + //break; + default: + $ac = StoredFile::RecallByGunid($gunid); + if (is_null($ac) || PEAR::isError($ac)) { + return $ac; + } + $r = $ac->md->getMetadataElement('dcterms:extent'); + if (PEAR::isError($r)) { + return $r; + } + $playlength = $r[0]['value']; + } + } + + $title = basename($tree->attrs['src']->val); + $offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val); + $clipStart = Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val); + $clipEnd = Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val); + $clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val); + $res = "$ind \n". + "$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n". + $fInfo. + "$ind \n"; + return $res; + } +} // class SmilPlaylistAudioElement + + +/** + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class SmilPlaylistAnimateElement { + + public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') + { + extract($parr); + if ($tree->name != 'animate') { + return PEAR::raiseError("SmilPlaylist::parse: animate tag expected"); + } + if ($tree->attrs['attributeName']->val == 'soundLevel' && + $tree->attrs['from']->val == '0%' && + $tree->attrs['to']->val == '100%' && + $tree->attrs['calcMode']->val == 'linear' && + $tree->attrs['fill']->val == 'freeze' && + $tree->attrs['begin']->val == '0s' && + preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va) + ) { + return array('type'=>'fadeIn', 'val'=>intval($va[1])); + } + if ($tree->attrs['attributeName']->val == 'soundLevel' && + $tree->attrs['from']->val == '100%' && + $tree->attrs['to']->val == '0%' && + $tree->attrs['calcMode']->val == 'linear' && + $tree->attrs['fill']->val == 'freeze' && + preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) && + preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd) + ) { + return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1])); + } + return PEAR::raiseError( + "SmilPlaylistAnimateElement::convert2lspl: animate parameters too general" + ); + } +} // class SmilPlaylistAnimateElement + +?> \ No newline at end of file diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php new file mode 100644 index 000000000..474445193 --- /dev/null +++ b/application/models/StoredFile.php @@ -0,0 +1,1787 @@ + "format", + "ls:bitrate" => "bit_rate", + "ls:samplerate" => "sample_rate", + "dcterms:extent" => "length", + "dc:title" => "track_title", + "dc:description" => "comments", + "dc:type" => "genre", + "dc:creator" => "artist_name", + "dc:source" => "album_title", + "ls:channels" => "channels", + "ls:filename" => "name", + "ls:year" => "year", + "ls:url" => "url", + "ls:track_num" => "track_number", + "ls:mood" => "mood", + "ls:bpm" => "bpm", + "ls:disc_num" => "disc_number", + "ls:rating" => "rating", + "ls:encoded_by" => "encoded_by", + "dc:publisher" => "label", + "ls:composer" => "composer", + "ls:encoder" => "encoder", + "ls:crc" => "checksum", + "ls:lyrics" => "lyrics", + "ls:orchestra" => "orchestra", + "ls:conductor" => "conductor", + "ls:lyricist" => "lyricist", + "ls:originallyricist" => "original_lyricist", + "ls:radiostationname" => "radio_station_name", + "ls:audiofileinfourl" => "info_url", + "ls:artisturl" => "artist_url", + "ls:audiosourceurl" => "audio_source_url", + "ls:radiostationurl" => "radio_station_url", + "ls:buycdurl" => "buy_this_url", + "ls:isrcnumber" => "isrc_number", + "ls:catalognumber" => "catalog_number", + "ls:originalartist" => "original_artist", + "dc:rights" => "copyright", + "dcterms:temporal" => "report_datetime", + "dcterms:spatial" => "report_location", + "dcterms:entity" => "report_organization", + "dc:subject" => "subject", + "dc:contributor" => "contributor", + "dc:language" => "language"); + +/** + * Track numbers in metadata tags can come in many formats: + * "1 of 20", "1/20", "20/1". This function parses the track + * number and gets the real number so that we can sort by it + * in the database. + * + * @param string $p_trackNumber + * @return int + */ +function camp_parse_track_number($p_trackNumber) +{ + $num = trim($p_trackNumber); + if (!is_numeric($num)) { + $matches = preg_match("/\s*([0-9]+)([^0-9]*)([0-9]*)\s*/", $num, $results); + $trackNum = 0; + foreach ($results as $result) { + if (is_numeric($result)) { + if ($trackNum == 0) { + $trackNum = $result; + } elseif ($result < $trackNum) { + $trackNum = $result; + } + } + } + } else { + $trackNum = $num; + } + return $trackNum; +} + + +/** + * Add data to the global array $mdata, also sets global variables + * $titleHaveSet and $titleKey. + * + * Converts the given string ($val) into UTF-8. + * + * @param array $p_mdata + * The array to add the metadata to. + * @param string $p_key + * Metadata key. + * @param string $p_val + * Metadata value. + * @param string $p_inputEncoding + * Encoding type of the input value. + */ +function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859-1') +{ + if (!is_null($p_val)) { + $data = $p_val; + $outputEncoding = 'UTF-8'; + //if (function_exists('iconv') && ($p_inputEncoding != $outputEncoding) ) { + if (function_exists('iconv') && is_string($p_val)) { + $newData = @iconv($p_inputEncoding, $outputEncoding, $data); + if ($newData === FALSE) { + echo "Warning: convert $key data to unicode failed\n"; + } elseif ($newData != $data) { + echo "Converted string: '$data' (".gettype($data).") -> '$newData' (".gettype($newData).").\n"; + $data = $newData; + } + } + $p_mdata[$p_key] = trim($data); + } +} + + +/** + * Return an array with the given audio file's ID3 tags. The keys in the + * array can be: + *+ * dc:format ("mime type") + * dcterms:extent ("duration") + * dc:title + * dc:creator ("artist") + * dc:source ("album") + * dc:type ("genre") + * ls:bitrate + * ls:encoded_by + * ls:track_num + * ls:channels + * ls:year + * ls:filename + *+ * + * @param string $p_filename + * @param boolean $p_testonly + * For diagnostic and debugging purposes - setting this to TRUE + * will print out the values found in the file and the ones assigned + * to the return array. + * @return array|PEAR_Error + */ +function camp_get_audio_metadata($p_filename, $p_testonly = false) +{ + $getID3 = new getID3(); + $infoFromFile = $getID3->analyze($p_filename); + if (PEAR::isError($infoFromFile)) { + return $infoFromFile; + } + if (isset($infoFromFile['error'])) { + return new PEAR_Error(array_pop($infoFromFile['error'])); + } + if (!$infoFromFile['bitrate']) { + return new PEAR_Error("File given is not an audio file."); + } + + if ($p_testonly) { + print_r($infoFromFile); + } + $titleKey = 'dc:title'; + $flds = array( + 'dc:format' => array( + array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE), + ), + 'ls:bitrate' => array( + array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE), + array('path'=>"['audio']['bitrate']", 'ignoreEnc'=>TRUE), + ), + 'ls:samplerate' => array( + array('path'=>"['audio']['sample_rate']", 'ignoreEnc'=>TRUE), + ), + 'ls:encoder' => array( + array('path'=>"['audio']['codec']", 'ignoreEnc'=>TRUE), + ), + 'dcterms:extent'=> array( + array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE), + ), + 'ls:composer'=> array( + array('path'=>"['id3v2']['comments']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), + array('path'=>"['id3v2']['TCOM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['id3v2']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), + array('path'=>"['ogg']['comments']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'dc:description'=> array( + array('path'=>"['id3v1']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['comments']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), + array('path'=>"['id3v2']['COMM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['id3v2']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), + array('path'=>"['ogg']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'dc:type'=> array( + array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), + array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'dc:title' => array( + array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'dc:creator' => array( + array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'dc:source' => array( + array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'ls:encoded_by' => array( + array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'ls:track_num' => array( + array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), + array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), +// 'ls:genre' => array( +// array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"), +// array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"), +// array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE), +// array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), +// array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), +// ), + 'ls:channels' => array( + array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE), + ), + 'ls:year' => array( + array('path'=>"['comments']['date']"), + array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"), + ), + 'ls:filename' => array( + array('path'=>"['filename']"), + ), + ); + $mdata = array(); + if (isset($infoFromFile['audio'])) { + $mdata['audio'] = $infoFromFile['audio']; + } + if (isset($infoFromFile['playtime_seconds'])) { + $mdata['playtime_seconds'] = $infoFromFile['playtime_seconds']; + } + + $titleHaveSet = FALSE; + foreach ($flds as $key => $getid3keys) { + foreach ($getid3keys as $getid3key) { + $path = $getid3key["path"]; + $ignoreEnc = isset($getid3key["ignoreEnc"])? + $getid3key["ignoreEnc"]:FALSE; + $dataPath = isset($getid3key["dataPath"])?$getid3key["dataPath"]:""; + $encPath = isset($getid3key["encPath"])?$getid3key["encPath"]:""; + $enc = "UTF-8"; + + $tagElement = "\$infoFromFile$path$dataPath"; + eval("\$tagExists = isset($tagElement);"); + if ($tagExists) { + //echo "ignore encoding: ".($ignoreEnc?"yes":"no")."\n"; + //echo "tag exists\n"; + //echo "encode path: $encPath\n"; + eval("\$data = $tagElement;"); + if (!$ignoreEnc && $encPath != "") { + $encodedElement = "\$infoFromFile$path$encPath"; + eval("\$encodedElementExists = isset($encodedElement);"); + if ($encodedElementExists) { + eval("\$enc = $encodedElement;"); + } + } + + // Special case handling for track number + if ($key == "ls:track_num") { + $data = camp_parse_track_number($data); + } + camp_add_metadata($mdata, $key, $data, $enc); + if ($key == $titleKey) { + $titleHaveSet = TRUE; + } + break; + } + } + } + if ($p_testonly) { + var_dump($mdata); + } + + if (!$titleHaveSet || trim($mdata[$titleKey]) == '') { + camp_add_metadata($mdata, $titleKey, basename($p_filename)); + } + return $mdata; +} + + +/** + * StoredFile class + * + * Campcaster file storage support class.
+ * Represents one virtual file in storage. Virtual file has up to two parts: + *+ *
+ * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + * @see MetaData + */ +class StoredFile { + + // *** Variables stored in the database *** + + /** + * @var int + */ + private $id; + + /** + * Unique ID for the file. This is stored in HEX format. It is + * converted to a bigint whenever it is used in a database call. + * + * @var string + */ + public $gunid; + + /** + * The unique ID of the file as it is stored in the database. + * This is for debugging purposes and may not always exist in this + * class. + * + * @var string + */ + //private $gunidBigint; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $mime; + + /** + * Can be 'audioclip'...others might be coming, like webstream. + * + * @var string + */ + private $ftype; + + /** + * Can be 'ready', 'edited', 'incomplete'. + * + * @var string + */ + private $state; + + /** + * @var int + */ + private $currentlyaccessing; + + /** + * @var int + */ + private $editedby; + + /** + * @var timestamp + */ + private $mtime; + + /** + * @var string + */ + private $md5; + + /** + * @var string + */ + private $filepath; + + + // *** Variables NOT stored in the database *** + + /** + * Directory where the file is located. + * + * @var string + */ + private $resDir; + + /** + * @var boolean + */ + private $exists; + + /** + * @var MetaData + */ + public $md; + + /* ========================================================== constructor */ + /** + * Constructor, but shouldn't be externally called + * + * @param string $p_gunid + * globally unique id of file + */ + public function __construct($p_gunid=NULL) + { + $this->gunid = $p_gunid; + if (empty($this->gunid)) { + $this->gunid = StoredFile::generateGunid(); + } + else { + $this->loadMetadata(); + $this->exists = is_file($this->filepath) && is_readable($this->filepath); + } + } + + /** + * For testing only, do not use. + */ + public function __setGunid($p_guid) { + $this->gunid = $p_guid; + } + + /** + * Convert XML name to database column name. Used for backwards compatibility + * with old code. + * + * @param string $p_category + * @return string|null + */ + public static function xmlCategoryToDbColumn($p_category) + { + global $g_metadata_xml_to_db_mapping; + if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) { + return $g_metadata_xml_to_db_mapping[$p_category]; + } + return null; + } + + + /** + * Convert database column name to XML name. + * + * @param string $p_dbColumn + * @return string|null + */ + public static function dbColumnToXmlCatagory($p_dbColumn) + { + global $g_metadata_xml_to_db_mapping; + $str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping); + // make return value consistent with xmlCategoryToDbColumn() + if ($str === FALSE) { + $str = null; + } + return $str; + } + + + /** + * GUNID needs to be set before you call this function. + * + */ + public function loadMetadata() + { + global $CC_CONFIG, $CC_DBC; + $escapedValue = pg_escape_string($this->gunid); + $sql = "SELECT * FROM ".$CC_CONFIG["filesTable"] + ." WHERE gunid='$escapedValue'"; + //var_dump($sql); + $this->md = $CC_DBC->getRow($sql); + //var_dump($this->md); + if (PEAR::isError($this->md)) { + $error = $this->md; + $this->md = null; + return $error; + } + $this->filepath = $this->md["filepath"]; + if (is_null($this->md)) { + $this->md = array(); + return; + } + $compatibilityData = array(); + foreach ($this->md as $key => $value) { + if ($xmlName = StoredFile::dbColumnToXmlCatagory($key)) { + $compatibilityData[$xmlName] = $value; + } + } + //var_dump($compatibilityData); + $this->md = array_merge($this->md, $compatibilityData); + //var_dump($this->md); + //$_SESSION["debug"] = $this->md; + } + + public function setFormat($p_value) + { + $this->md["format"] = $p_value; + } + + public function replaceMetadata($p_values) + { + global $CC_CONFIG, $CC_DBC; + foreach ($p_values as $category => $value) { + $escapedValue = pg_escape_string($value); + $columnName = StoredFile::xmlCategoryToDbColumn($category); + if (!is_null($columnName)) { + $sql = "UPDATE ".$CC_CONFIG["filesTable"] + ." SET $columnName='$escapedValue'" + ." WHERE gunid = '".$this->gunid."'"; + $CC_DBC->query($sql); + } + } + $this->loadMetadata(); + } + + public function clearMetadata() + { + $metadataColumns = array("format", "bit_rate", "sample_rate", "length", + "track_title", "comments", "genre", "artist_name", "channels", "name", + "year", "url", "track_number"); + foreach ($metadataColumns as $columnName) { + if (!is_null($columnName)) { + $sql = "UPDATE ".$CC_CONFIG["filesTable"] + ." SET $columnName=''" + ." WHERE gunid = '".$this->gunid."'"; + $CC_DBC->query($sql); + } + } + } + + + /* ========= 'factory' methods - should be called to construct StoredFile */ + /** + * Create instance of StoredFile object and insert new file + * + * @param array $p_values + * "filepath" - required, local path to media file (where it is before import) + * "id" - optional, local object id, will be generated if not given + * "gunid" - optional, unique id, for insert file with gunid, will be generated if not given + * "filename" - optional, will use "filepath" if not given + * "metadata" - optional, array of extra metadata, will be automatically calculated if not given. + * "mime" - optional, MIME type, highly recommended to pass in, will be automatically calculated if not given. + * "md5" - optional, MD5 sum, highly recommended to pass in, will be automatically calculated if not given. + * + * @param boolean $p_copyMedia + * copy the media file if true, make symlink if false + * + * @return StoredFile|NULL|PEAR_Error + */ + public static function Insert($p_values, $p_copyMedia=TRUE) + { + global $CC_CONFIG, $CC_DBC; + + if (!isset($p_values["filepath"])) { + return new PEAR_Error("StoredFile::Insert: filepath not set."); + } + if (!file_exists($p_values['filepath'])) { + return PEAR::raiseError("StoredFile::Insert: ". + "media file not found ({$p_values['filepath']})"); + } + + $gunid = isset($p_values['gunid'])?$p_values['gunid']:NULL; + + // Create the StoredFile object + $storedFile = new StoredFile($gunid); + + // Get metadata + if (isset($p_values["metadata"])) { + $metadata = $p_values['metadata']; + } else { + $metadata = camp_get_audio_metadata($p_values["filepath"]); + } + + $storedFile->name = isset($p_values['filename']) ? $p_values['filename'] : $p_values["filepath"]; + $storedFile->id = isset($p_values['id']) && is_integer($p_values['id'])?(int)$p_values['id']:null; + // NOTE: POSTGRES-SPECIFIC KEYWORD "DEFAULT" BEING USED, WOULD BE "NULL" IN MYSQL + $sqlId = !is_null($storedFile->id)?"'".$storedFile->id."'":'DEFAULT'; + $storedFile->ftype = isset($p_values['filetype']) ? strtolower($p_values['filetype']) : "audioclip"; + $storedFile->mime = (isset($p_values["mime"]) ? $p_values["mime"] : NULL ); + // $storedFile->filepath = $p_values['filepath']; + if (isset($p_values['md5'])) { + $storedFile->md5 = $p_values['md5']; + } elseif (file_exists($p_values['filepath'])) { + //echo "StoredFile::Insert: WARNING: Having to recalculate MD5 value\n"; + $storedFile->md5 = md5_file($p_values['filepath']); + } + + // Check for duplicates -- return duplicate + $duplicate = StoredFile::RecallByMd5($storedFile->md5); + if ($duplicate) { + return $duplicate; + } + + $storedFile->exists = FALSE; + + // Insert record into the database + $escapedName = pg_escape_string($storedFile->name); + $escapedFtype = pg_escape_string($storedFile->ftype); + $sql = "INSERT INTO ".$CC_CONFIG['filesTable'] + ."(id, name, gunid, mime, state, ftype, mtime, md5)" + ."VALUES ({$sqlId}, '{$escapedName}', " + ." '{$storedFile->gunid}'," + ." '{$storedFile->mime}', 'incomplete', '$escapedFtype'," + ." now(), '{$storedFile->md5}')"; + //$_SESSION["debug"] .= "sql: ".$sql."- metadata in database - represented by MetaData class
+ *- binary media data in real file
+ *
"; + //echo $sql."\n"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + $CC_DBC->query("ROLLBACK"); + return $res; + } + + if (!is_integer($storedFile->id)) { + // NOTE: POSTGRES-SPECIFIC + $sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."_seq')"; + $storedFile->id = $CC_DBC->getOne($sql); + } + $storedFile->setMetadataBatch($metadata); + + // Save media file + $res = $storedFile->addFile($p_values['filepath'], $p_copyMedia); + if (PEAR::isError($res)) { + echo "StoredFile::Insert -- addFile(): '".$res->getMessage()."'\n"; + return $res; + } + + if (empty($storedFile->mime)) { + //echo "StoredFile::Insert: WARNING: Having to recalculate MIME value\n"; + $storedFile->setMime($storedFile->getMime()); + } + + // Save state + $storedFile->setState('ready'); + + // Recall the object to get all the proper values + $storedFile = StoredFile::RecallByGunid($storedFile->gunid); + return $storedFile; + } + + /** + * Fetch instance of StoreFile object.
+ * Should be supplied with only ONE parameter, all the rest should + * be NULL. + * + * @param int $p_id + * local id + * @param string $p_gunid + * global unique id of file + * @param string $p_md5sum + * MD5 sum of the file + * @return StoredFile|Playlist|NULL + * Return NULL if the object doesnt exist in the DB. + */ + public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null) + { + global $CC_DBC; + global $CC_CONFIG; + if (!is_null($p_id)) { + $cond = "id='".intval($p_id)."'"; + } elseif (!is_null($p_gunid)) { + $cond = "gunid='$p_gunid'"; + } elseif (!is_null($p_md5sum)) { + $cond = "md5='$p_md5sum'"; + } else { + return null; + } + $sql = "SELECT *" + ." FROM ".$CC_CONFIG['filesTable'] + ." WHERE $cond"; + //echo $sql; + $row = $CC_DBC->getRow($sql); + if (PEAR::isError($row) || is_null($row)) { + return $row; + } + $gunid = $row['gunid']; + $storedFile = new StoredFile($gunid); + $storedFile->id = $row['id']; + $storedFile->name = $row['name']; + $storedFile->mime = $row['mime']; + $storedFile->ftype = $row['ftype']; + $storedFile->state = $row['state']; + $storedFile->currentlyaccessing = $row['currentlyaccessing']; + $storedFile->editedby = $row['editedby']; + $storedFile->mtime = $row['mtime']; + $storedFile->md5 = $row['md5']; + $storedFile->filepath = $row['filepath']; + $storedFile->exists = TRUE; + $storedFile->setFormat($row['ftype']); + return $storedFile; + } + + + /** + * Create instance of StoreFile object and recall existing file + * by gunid. + * + * @param string $p_gunid + * global unique id of file + * @return StoredFile + */ + public static function RecallByGunid($p_gunid='') + { + return StoredFile::Recall(null, $p_gunid); + } + + + /** + * Fetch the StoredFile by looking up the MD5 value. + * + * @param string $p_md5sum + * @return StoredFile|NULL|PEAR_Error + */ + public static function RecallByMd5($p_md5sum) + { + return StoredFile::Recall(null, null, $p_md5sum); + } + + + /** + * Create instance of StoreFile object and recall existing file + * by access token. + * + * @param string $p_token + * access token + * @return StoredFile + */ + public static function RecallByToken($p_token) + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT gunid" + ." FROM ".$CC_CONFIG['accessTable'] + ." WHERE token=x'$p_token'::bigint"; + $gunid = $CC_DBC->getOne($sql); + if (PEAR::isError($gunid)) { + return $gunid; + } + if (is_null($gunid)) { + return PEAR::raiseError( + "StoredFile::RecallByToken: invalid token ($p_token)", GBERR_AOBJNEX); + } + return StoredFile::Recall(null, $gunid); + } + + + /** + * Generate the location to store the file. + * It creates the subdirectory if needed. + */ + private function generateFilePath() + { + global $CC_CONFIG, $CC_DBC; + $resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3); + // see Transport::_getResDir too for resDir name create code + if (!is_dir($resDir)) { + mkdir($resDir, 02775); + chmod($resDir, 02775); + } + $info = pathinfo($this->name); + $fileExt = strtolower($info["extension"]); + return "{$resDir}/{$this->gunid}.{$fileExt}"; + } + + /** + * Insert media file to filesystem + * + * @param string $p_localFilePath + * local path + * @param boolean $p_copyMedia + * copy the media file if true, make symlink if false + * @return TRUE|PEAR_Error + */ + public function addFile($p_localFilePath, $p_copyMedia=TRUE) + { + global $CC_CONFIG, $CC_DBC; + if ($this->exists) { + return FALSE; + } + // for files downloaded from remote instance: + if ($p_localFilePath == $this->filepath) { + $this->exists = TRUE; + return TRUE; + } + umask(0002); + $dstFile = ''; + if ($p_copyMedia) { + $dstFile = $this->generateFilePath(); + $r = @copy($p_localFilePath, $dstFile); + if (!$r) { + $this->exists = FALSE; + return PEAR::raiseError( + "StoredFile::addFile: file save failed". + " ($p_localFilePath, {$this->filepath})",GBERR_FILEIO + ); + } + } else { + $dstFile = $p_localFilePath; + $r = TRUE; + //$r = @symlink($p_localFilePath, $dstFile); + } + $this->filepath = $dstFile; + $sqlPath = pg_escape_string($this->filepath); + $sql = "UPDATE ".$CC_CONFIG["filesTable"] + ." SET filepath='{$sqlPath}'" + ." WHERE id={$this->id}"; + //echo $sql."\n"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $this->exists = TRUE; + return TRUE; + } + + + /** + * Delete and insert media file + * + * @param string $p_localFilePath + * local path + * @return TRUE|PEAR_Error + */ + public function replaceFile($p_localFilePath) + { + // Dont do anything if the source and destination files are + // the same. + if ($this->name == $p_localFilePath) { + return TRUE; + } + + if ($this->exists) { + $r = $this->deleteFile(); + if (PEAR::isError($r)) { + return $r; + } + } + return $this->addFile($p_localFilePath); + } + + + /** + * Return true if file corresponding to the object exists + * + * @return boolean + */ + public function existsFile() + { + return $this->exists; + } + + + /** + * Delete media file from filesystem. + * You cant delete a file if it is being accessed. + * You cant delete a file if it is scheduled to be played in the future. + * The file will be removed from all playlists it is a part of. + * + * @return boolean|PEAR_Error + */ + public function deleteFile() + { + global $CC_CONFIG; + if (!$this->exists) { + return FALSE; + } + if ($this->isAccessed()) { + return PEAR::raiseError( + 'Cannot delete a file that is currently accessed.' + ); + } + + // Check if the file is scheduled to be played in the future + if (Schedule::IsFileScheduledInTheFuture($this->id)) { + return PEAR::raiseError( + 'Cannot delete a file that is scheduled in the future.' + ); + } + + // Delete it from all playlists + //Playlist::DeleteFileFromAllPlaylists($this->id); + + // Only delete the file from filesystem if it has been copied to the + // storage directory. (i.e. dont delete linked files) + if (substr($this->filepath, 0, strlen($CC_CONFIG["storageDir"])) == $CC_CONFIG["storageDir"]) { + // Delete the file + if (!file_exists($this->filepath) || @unlink($this->filepath)) { + $this->exists = FALSE; + return TRUE; + } else { + return PEAR::raiseError( + "StoredFile::deleteFile: unlink failed ({$this->filepath})", + GBERR_FILEIO + ); + } + } else { + $this->exists = FALSE; + return TRUE; + } + } + + + /** + * Analyze file with getid3 module.
+ * Obtain some metadata stored in media file.
+ * This method should be used for prefilling metadata input form. + * + * @return array + * hierarchical hasharray with information about media file + */ + public function analyzeFile() + { + if (!$this->exists) { + return FALSE; + } + $ia = camp_get_audio_metadata($this->filepath); + return $ia; + } + + + /** + * Create instance of StoredFile object and make copy of existing file + * + * @param StoredFile $p_src + * source object + * @param int $p_nid + * new local id + * @return StoredFile + */ + public static function CopyOf(&$p_src, $p_nid) + { + $values = array( + "id" => $p_nid, + "filename" => $p_src->name, + "filepath" => $p_src->getRealFileName(), + "filetype" => $p_src->getType() + ); + $storedFile = StoredFile::Insert($values); + if (PEAR::isError($storedFile)) { + return $storedFile; + } + $storedFile->replaceMetadata($p_src->getAllMetadata(), 'string'); + return $storedFile; + } + + + /** + * Replace existing file with new data. + * + * @param int $p_oid + * NOT USED + * @param string $p_name + * name of file + * @param string $p_localFilePath + * local path to media file + * @param string $p_metadata + * local path to metadata XML file or XML string + * @param string $p_mdataLoc + * 'file'|'string' + * @return TRUE|PEAR_Error + */ +// public function replace($p_oid, $p_name, $p_localFilePath='', $p_metadata='', +// $p_mdataLoc='file') +// { +// global $CC_CONFIG, $CC_DBC; +// $CC_DBC->query("BEGIN"); +// $res = $this->setName($p_name); +// if (PEAR::isError($res)) { +// $CC_DBC->query("ROLLBACK"); +// return $res; +// } +// if ($p_localFilePath != '') { +// $res = $this->setRawMediaData($p_localFilePath); +// } else { +// $res = $this->deleteFile(); +// } +// if (PEAR::isError($res)) { +// $CC_DBC->query("ROLLBACK"); +// return $res; +// } +// if ($p_metadata != '') { +// $res = $this->setMetadata($p_metadata, $p_mdataLoc); +// } else { +//// $res = $this->md->delete(); +// $res = $this->clearMetadata(); +// } +// if (PEAR::isError($res)) { +// $CC_DBC->query("ROLLBACK"); +// return $res; +// } +// $res = $CC_DBC->query("COMMIT"); +// if (PEAR::isError($res)) { +// $CC_DBC->query("ROLLBACK"); +// return $res; +// } +// return TRUE; +// } + + + /** + * Increase access counter, create access token, insert access record. + * + * @param int $parent + * parent token + * @return array + * array with: access URL, access token + */ + public function accessRawMediaData($p_parent='0') + { + $realFname = $this->getRealFileName(); + $ext = $this->getFileExtension(); + $res = BasicStor::bsAccess($realFname, $ext, $this->gunid, 'access', $p_parent); + if (PEAR::isError($res)) { + return $res; + } + $resultArray = + array('url'=>"file://{$res['fname']}", 'token'=>$res['token']); + return $resultArray; + } + + + /** + * Decrease access couter, delete access record. + * + * @param string $p_token + * access token + * @return boolean + */ + public function releaseRawMediaData($p_token) + { + $res = BasicStor::bsRelease($p_token); + if (PEAR::isError($res)) { + return $res; + } + return TRUE; + } + + + /** + * Replace media file only with new binary file + * + * @param string $p_localFilePath + * local path to media file + * @return TRUE|PEAR_Error + */ + public function setRawMediaData($p_localFilePath) + { + $res = $this->replaceFile($p_localFilePath); + if (PEAR::isError($res)) { + return $res; + } + $mime = $this->getMime(); + if ($mime !== FALSE) { + $res = $this->setMime($mime); + if (PEAR::isError($res)) { + return $res; + } + } +// $r = $this->md->regenerateXmlFile(); +// if (PEAR::isError($r)) { +// return $r; +// } + return TRUE; + } + + + private static function NormalizeExtent($v) + { + if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) { + $s = Playlist::playlistTimeToSeconds($v); + $t = Playlist::secondsToPlaylistTime($s); + return $t; + } + return $v; + } + + + /** + * Replace metadata with new XML file + * + * @param string $p_metadata + * local path to metadata XML file or XML string + * @param string $p_mdataLoc + * 'file'|'string' + * @param string $p_format + * metadata format for validation + * ('audioclip' | 'playlist' | 'webstream' | NULL) + * (NULL = no validation) + * @return boolean + */ +// public function setMetadata($p_metadata, $p_mdataLoc='file', $p_format=NULL) +// { +// global $CC_CONFIG, $CC_DBC; +// $CC_DBC->query("BEGIN"); +// $res = $this->md->replace($p_metadata, $p_mdataLoc, $p_format); +// if (PEAR::isError($res)) { +// $CC_DBC->query("ROLLBACK"); +// return $res; +// } +// $res = $CC_DBC->query("COMMIT"); +// if (PEAR::isError($res)) { +// return $res; +// } +// return TRUE; +// } + + /** + * Set metadata element value + * + * @param string $category + * Metadata element identification (e.g. dc:title) + * @param string $value + * value to store, if NULL then delete record + * @return boolean + */ + public function setMetadataValue($p_category, $p_value) + { + global $CC_CONFIG, $CC_DBC; + if (!is_string($p_category) || is_array($p_value)) { + return FALSE; + } + if ($p_category == 'dcterms:extent') { + $p_value = StoredFile::NormalizeExtent($p_value); + } + $columnName = StoredFile::xmlCategoryToDbColumn($p_category); // Get column name + + if (!is_null($columnName)) { + $escapedValue = pg_escape_string($p_value); + $sql = "UPDATE ".$CC_CONFIG["filesTable"] + ." SET $columnName='$escapedValue'" + ." WHERE id={$this->id}"; + //var_dump($sql); + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + } + return TRUE; + } + + + /** + * Set metadata values in 'batch' mode + * + * @param array $values + * array of key/value pairs + * (e.g. 'dc:title'=>'New title') + * @return boolean + */ + public function setMetadataBatch($values) + { + global $CC_CONFIG, $CC_DBC; + if (!is_array($values)) { + $values = array($values); + } + if (count($values) == 0) { + return true; + } + foreach ($values as $category => $oneValue) { + $columnName = StoredFile::xmlCategoryToDbColumn($category); + if (!is_null($columnName)) { + if ($category == 'dcterms:extent') { + $oneValue = StoredFile::NormalizeExtent($oneValue); + } + // Since track_number is an integer, you cannot set + // it to be the empty string, so we NULL it instead. + if ($columnName == 'track_number' && empty($oneValue)) { + $sqlPart = "$columnName = NULL"; + } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) { + // Postgres doesnt like it if you try to store really large hour + // values. TODO: We need to fix the underlying problem of getting the + // right values. + $parts = explode(':', $oneValue); + $hour = intval($parts[0]); + if ($hour > 24) { + continue; + } else { + $sqlPart = "$columnName = '$oneValue'"; + } + } else { + $escapedValue = pg_escape_string($oneValue); + $sqlPart = "$columnName = '$escapedValue'"; + } + $sqlValues[] = $sqlPart; + } + } + if (count($sqlValues)==0) { + return TRUE; + } + $sql = "UPDATE ".$CC_CONFIG["filesTable"] + ." SET ".join(",", $sqlValues) + ." WHERE id={$this->id}"; + $CC_DBC->query($sql); + return TRUE; + } + + + /** + * Get metadata as array, indexed by the column names in the database. + * + * @return array + */ + public function getMetadata() + { + return $this->md; + } + + /** + * Get one metadata value. + * + * @param string $p_name + * @return string + */ + public function getMetadataValue($p_name) + { + if (isset($this->md[$p_name])){ + return $this->md[$p_name]; + } else { + return ""; + } + } + + /** + * Rename stored virtual file + * + * @param string $p_newname + * @return TRUE|PEAR_Error + */ + public function setName($p_newname) + { + global $CC_CONFIG, $CC_DBC; + $escapedName = pg_escape_string($p_newname); + $sql = "UPDATE ".$CC_CONFIG['filesTable'] + ." SET name='$escapedName', mtime=now()" + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $this->name = $p_newname; + return TRUE; + } + + + /** + * Set state of virtual file + * + * @param string $p_state + * 'empty'|'incomplete'|'ready'|'edited' + * @param int $p_editedby + * user id | 'NULL' for clear editedBy field + * @return TRUE|PEAR_Error + */ + public function setState($p_state, $p_editedby=NULL) + { + global $CC_CONFIG, $CC_DBC; + $escapedState = pg_escape_string($p_state); + $eb = (!is_null($p_editedby) ? ", editedBy=$p_editedby" : ''); + $sql = "UPDATE ".$CC_CONFIG['filesTable'] + ." SET state='$escapedState'$eb, mtime=now()" + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $this->state = $p_state; + $this->editedby = $p_editedby; + return TRUE; + } + + /** + * Set mime-type of virtual file + * + * @param string $p_mime + * mime-type + * @return boolean|PEAR_Error + */ + public function setMime($p_mime) + { + global $CC_CONFIG, $CC_DBC; + if (!is_string($p_mime)) { + $p_mime = 'application/octet-stream'; + } + $escapedMime = pg_escape_string($p_mime); + $sql = "UPDATE ".$CC_CONFIG['filesTable'] + ." SET mime='$escapedMime', mtime=now()" + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $this->mime = $p_mime; + return TRUE; + } + + + /** + * Set md5 of virtual file + * + * @param string $p_md5sum + * @return boolean|PEAR_Error + */ + public function setMd5($p_md5sum) + { + global $CC_CONFIG, $CC_DBC; + $escapedMd5 = pg_escape_string($p_md5sum); + $sql = "UPDATE ".$CC_CONFIG['filesTable'] + ." SET md5='$escapedMd5', mtime=now()" + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $this->md5 = $p_md5sum; + return TRUE; + } + + + /** + * Delete stored virtual file + * + * @param boolean $p_deleteFile + * + * @return TRUE|PEAR_Error + */ + public function delete($p_deleteFile = true) + { + global $CC_CONFIG, $CC_DBC; + if ($p_deleteFile) { + $res = $this->deleteFile(); + if (PEAR::isError($res)) { + return $res; + } + } + $sql = "SELECT to_hex(token)as token, ext " + ." FROM ".$CC_CONFIG['accessTable'] + ." WHERE gunid='{$this->gunid}'"; + $tokens = $CC_DBC->getAll($sql); + if (is_array($tokens)) { + foreach ($tokens as $i => $item) { + $file = $this->_getAccessFileName($item['token'], $item['ext']); + if (file_exists($file)) { + @unlink($file); + } + } + } + $sql = "DELETE FROM ".$CC_CONFIG['accessTable'] + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + $sql = "DELETE FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='{$this->gunid}'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + return TRUE; + } + + + /** + * Returns an array of playlist objects that this file is a part of. + * @return array + */ + public function getPlaylists() { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT playlist_id " + ." FROM ".$CC_CONFIG['playistTable'] + ." WHERE file_id='{$this->id}'"; + $ids = $CC_DBC->getAll($sql); + $playlists = array(); + if (is_array($ids) && count($ids) > 0) { + foreach ($ids as $id) { + $playlists[] = Playlist::Recall($id); + } + } + return $playlists; + } + + + /** + * Returns true if virtual file is currently in use.
+ * Static or dynamic call is possible. + * + * @param string $p_gunid + * optional (for static call), global unique id + * @return boolean|PEAR_Error + */ + public function isAccessed($p_gunid=NULL) + { + global $CC_CONFIG, $CC_DBC; + if (is_null($p_gunid)) { + return ($this->currentlyaccessing > 0); + } + $sql = "SELECT currentlyAccessing FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='$p_gunid'"; + $ca = $CC_DBC->getOne($sql); + if (is_null($ca)) { + return PEAR::raiseError( + "StoredFile::isAccessed: invalid gunid ($p_gunid)", + GBERR_FOBJNEX + ); + } + return ($ca > 0); + } + + + /** + * Returns true if virtual file is edited + * + * @param string $p_playlistId + * playlist global unique ID + * @return boolean + */ + public function isEdited($p_playlistId=NULL) + { + if (is_null($p_playlistId)) { + return ($this->state == 'edited'); + } + $state = $this->getState($p_playlistId); + if ($state != 'edited') { + return FALSE; + } + return TRUE; + } + + + /** + * Returns id of user editing playlist + * + * @param string $p_playlistId + * playlist global unique ID + * @return int|null|PEAR_Error + * id of user editing it + */ + public function isEditedBy($p_playlistId=NULL) + { + global $CC_CONFIG, $CC_DBC; + if (is_null($p_playlistId)) { + $p_playlistId = $this->gunid; + } + $sql = "SELECT editedBy FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='$p_playlistId'"; + $ca = $CC_DBC->getOne($sql); + if (PEAR::isError($ca)) { + return $ca; + } + if (is_null($ca)) { + return $ca; + } + return intval($ca); + } + + + /** + * Return local ID of virtual file. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + + /** + * Return global ID of virtual file. + * + * @return string + */ + public function getGunid() + { + return $this->gunid; + } + + + /** + * Returns true if raw media file exists + * @return boolean|PEAR_Error + */ + public function exists() + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT gunid " + ." FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='{$this->gunid}'"; + $indb = $CC_DBC->getRow($sql); + if (PEAR::isError($indb)) { + return $indb; + } + if (is_null($indb)) { + return FALSE; + } + if ($this->ftype == 'audioclip') { + return $this->existsFile(); + } + return TRUE; + } + + + /** + * Create new global unique id + * @return string + */ + public static function generateGunid() + { + return md5(uniqid("", true)); + +// $ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''); +// $initString = microtime().$ip.rand(); +// $hash = md5($initString); +// // non-negative int8 +// $hsd = substr($hash, 0, 1); +// $res = dechex(hexdec($hsd)>>1).substr($hash, 1, 15); +// return StoredFile::NormalizeGunid($res); + } + + + /** + * Pad the gunid with zeros if it isnt 16 digits. + * + * @return string + */ +// public static function NormalizeGunid($p_gunid) +// { +// return str_pad($p_gunid, 16, "0", STR_PAD_LEFT); +// } + + + /** + * Return suitable extension. + * + * @todo make it general - is any tool for it? + * + * @return string + * file extension without a dot + */ + public function getFileExtension() + { + $fname = $this->getName(); + $pos = strrpos($fname, '.'); + if ($pos !== FALSE) { + $ext = substr($fname, $pos+1); + if ($ext !== FALSE) { + return $ext; + } + } + switch (strtolower($this->mime)) { + case "audio/mpeg": + $ext = "mp3"; + break; + case "audio/x-wav": + case "audio/x-wave": + $ext = "wav"; + break; + case "audio/x-ogg": + case "application/x-ogg": + $ext = "ogg"; + break; + default: + $ext = "bin"; + break; + } + return $ext; + } + + + /** + * Get mime-type stored in the file. + * Warning: this function is slow! + * + * @return string + */ + public function getMime() + { + $a = $this->analyzeFile(); + if (PEAR::isError($a)) { + return $a; + } + if (isset($a['dc:format'])) { + return $a['dc:format']; + } + return ''; + } + + + /** + * Convenience function. + * @return string + */ + public function getTitle() + { + return $this->md["title"]; + } + + public function getType() + { + return $this->ftype; + } + + /** + * Get storage-internal file state + * + * @param string $p_gunid + * global unique id of file + * @return string + * see install() + */ + public function getState($p_gunid=NULL) + { + global $CC_CONFIG, $CC_DBC; + if (is_null($p_gunid)) { + return $this->state; + } + $sql = "SELECT state FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='$p_gunid'"; + return $CC_DBC->getOne($sql); + } + + + /** + * Get mnemonic file name + * + * @param string $p_gunid + * global unique id of file + * @return string + */ + public function getName($p_gunid=NULL) + { + global $CC_CONFIG, $CC_DBC; + if (is_null($p_gunid)) { + return $this->name; + } + $sql = "SELECT name FROM ".$CC_CONFIG['filesTable'] + ." WHERE gunid='$p_gunid'"; + return $CC_DBC->getOne($sql); + } + + + /** + * Get and optionally create subdirectory in real filesystem for storing + * raw media data. + * + * @return string + */ +// private function _getResDir() +// { +// global $CC_CONFIG, $CC_DBC; +// $resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3); +// //$this->gb->debugLog("$resDir"); +// // see Transport::_getResDir too for resDir name create code +// if (!is_dir($resDir)) { +// mkdir($resDir, 02775); +// chmod($resDir, 02775); +// } +// return $resDir; +// } + + + /** + * Get real filename of raw media data + * + * @return string + */ + public function getRealFileName() + { + return $this->filepath; + } + + /** + * Get the URL to access this file. + */ + public function getFileUrl() + { + global $CC_CONFIG; + return "http://".$CC_CONFIG["storageUrlHost"] + ."api/get_media.php?file_id={$this->gunid}"; + } + + /** + * Get real filename of metadata file + * + * @return string + * @see MetaData + */ + public function getRealMetadataFileName() + { + //return $this->md->getFileName(); + return $this->md["name"]; + } + + + /** + * Create and return name for temporary symlink. + * + * @todo Should be more unique + * @return string + */ + private function _getAccessFileName($p_token, $p_ext='EXT') + { + global $CC_CONFIG; + return $CC_CONFIG['accessDir']."/$p_token.$p_ext"; + } + + public static function getFiles($query=NULL) + { + global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping; + + $sql = "SELECT * FROM ".$CC_CONFIG['filesTable']; + + if(!is_null($query)) { + $ob = " ORDER BY ".$g_metadata_xml_to_db_mapping[$query["category"]]; + $sql = $sql . $ob . " " .$query["order"]; + } + + return $CC_DBC->getAll($sql); + } + + public static function searchFiles($md) + { + global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping; + + $match = array( + "0" => "ILIKE", + "1" => "=", + "2" => "<", + "3" => "<=", + "4" => ">", + "5" => ">=", + "6" => "!=", + ); + + $sql = "SELECT * FROM ".$CC_CONFIG['filesTable']; + + $cond = array(); + foreach(array_keys($md) as $key) { + if(strpos($key, 'row') !== false){ + $t = explode("_", $key); + $row_num = $t[1]; + + $string = $g_metadata_xml_to_db_mapping[$md[$key]["metadata_".$row_num]]; + + $string = $string ." ".$match[$md[$key]["match_".$row_num]]; + + if ($md[$key]["match_".$row_num] === "0") + $string = $string." '%". $md[$key]["search_".$row_num]."%'"; + else + $string = $string." '". $md[$key]["search_".$row_num]."'"; + + $cond[] = $string; + } + } + + $where = " WHERE ". join(" AND ", $cond); + $sql = $sql . $where; + //echo $sql; + + return $CC_DBC->getAll($sql); + } + +} // class StoredFile +?> diff --git a/application/models/Subjects.php b/application/models/Subjects.php new file mode 100644 index 000000000..f99cea1c6 --- /dev/null +++ b/application/models/Subjects.php @@ -0,0 +1,683 @@ +raiseError("Subjects::AddSubj: empty login"); + } + $id = $CC_DBC->nextId($CC_CONFIG['subjSequence']); + if (PEAR::isError($id)) { + return $id; + } + if (!is_null($p_pass) && !$p_passenc) { + $p_pass = md5($p_pass); + } + $sql = "INSERT INTO ".$CC_CONFIG['subjTable']." (id, login, pass, type, realname)" + ." VALUES ($id, '$p_login', ". + (is_null($p_pass) ? "'!', 'G'" : "'$p_pass', 'U'").", + '$p_realname')"; + $r = $CC_DBC->query($sql); + if (PEAR::isError($r)) { + return $r; + } + return $id; + } + + + /** + * Remove subject by uid or by login + * + * @param string $login + * @param int $uid + * @return boolean|PEAR_Error + */ + public static function RemoveSubj($login, $uid=NULL) + { + global $CC_CONFIG, $CC_DBC; + if (is_null($uid)) { + $uid = Subjects::GetSubjId($login); + } + if (PEAR::isError($uid)) { + return $uid; + } + $sql = "DELETE FROM ".$CC_CONFIG['smembTable'] + ." WHERE (uid='$uid' OR gid='$uid') AND mid is null"; + $r = $CC_DBC->query($sql); + if (PEAR::isError($r)) { + return $r; + } + $sql2 = "DELETE FROM ".$CC_CONFIG['subjTable'] + ." WHERE login='$login'"; + $r = $CC_DBC->query($sql2); + if (PEAR::isError($r)) { + return $r; + } + return Subjects::_rebuildRels(); + } // fn removeSubj + + + /** + * Check login and password + * + * @param string $login + * @param string $pass + * optional + * @return boolean|int|PEAR_Error + */ + public static function Authenticate($login, $pass='') + { + global $CC_CONFIG, $CC_DBC; + $cpass = md5($pass); + $sql = "SELECT id FROM ".$CC_CONFIG['subjTable'] + ." WHERE login='$login' AND pass='$cpass' AND type='U'"; + $id = $CC_DBC->getOne($sql); + if (PEAR::isError($id)) { + return $id; + } + return (is_null($id) ? FALSE : $id); + } // fn authenticate + + + /** + * Set lastlogin or lastfail timestamp + * + * @param string $login + * @param boolean $failed + * true=> set lastfail, false=> set lastlogin + * @return boolean|int|PEAR_Error + */ + public static function SetTimeStamp($login, $failed=FALSE) + { + global $CC_CONFIG, $CC_DBC; + $fld = ($failed ? 'lastfail' : 'lastlogin'); + $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET $fld=now()" + ." WHERE login='$login'"; + $r = $CC_DBC->query($sql); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } // fn setTimeStamp + + + /** + * Change user password + * + * @param string $login + * @param string $oldpass + * old password (optional for 'superuser mode') + * @param string $pass + * optional + * @param boolean $passenc + * optional, password already encrypted if true + * @return boolean|PEAR_Error + */ + public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE) + { + global $CC_CONFIG, $CC_DBC; + if (!$passenc) { + $cpass = md5($pass); + } else { + $cpass = $pass; + } + if (!is_null($oldpass)) { + $oldcpass = md5($oldpass); + $oldpCond = "AND pass='$oldcpass'"; + } else { + $oldpCond = ''; + } + $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'" + ." WHERE login='$login' $oldpCond AND type='U'"; + $r = $CC_DBC->query($sql); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } // fn passwd + + + /* --------------------------------------------------------------- groups */ + + /** + * Add {login} and direct/indirect members to {gname} and to groups, + * where {gname} is [in]direct member + * + * @param string $login + * @param string $gname + * @return int|PEAR_Error + */ + public static function AddSubjectToGroup($login, $gname) + { + $uid = Subjects::GetSubjId($login); + if (PEAR::isError($uid)) { + return $uid; + } + $gid = Subjects::GetSubjId($gname); + if (PEAR::isError($gid)) { + return $gid; + } + $isgr = Subjects::IsGroup($gid); + if (PEAR::isError($isgr)) { + return $isgr; + } + if (!$isgr) { + return PEAR::raiseError("Subjects::addSubj2Gr: Not a group ($gname)", ALIBERR_NOTGR); + } + // add subject and all [in]direct members to group $gname: + $mid = Subjects::_plainAddSubjectToGroup($uid, $gid); + if (PEAR::isError($mid)) { + return $mid; + } + // add it to all groups where $gname is [in]direct member: + $marr = Subjects::_listRMemb($gid); + if (PEAR::isError($marr)) { + return $marr; + } + foreach ($marr as $k => $v) { + $r = Subjects::_plainAddSubjectToGroup( + $uid, $v['gid'], intval($v['level'])+1, $v['id']); + if (PEAR::isError($r)) { + return $r; + } + } + return $mid; + } // fn addSubj2Gr + + + /** + * Remove subject from group + * + * @param string $login + * @param string $gname + * @return boolean|PEAR_Error + */ + public static function RemoveSubjectFromGroup($login, $gname) + { + global $CC_CONFIG, $CC_DBC; + $uid = Subjects::GetSubjId($login); + if (PEAR::isError($uid)) { + return $uid; + } + $gid = Subjects::GetSubjId($gname); + if (PEAR::isError($gid)) { + return $gid; + } + $sql = "SELECT id FROM ".$CC_CONFIG['smembTable'] + ." WHERE uid='$uid' AND gid='$gid' AND mid is null"; + $mid = $CC_DBC->getOne($sql); + if (is_null($mid)) { + return FALSE; + } + if (PEAR::isError($mid)) { + return $mid; + } + // remove it: + $r = Subjects::_removeMemb($mid); + if (PEAR::isError($r)) { + return $r; + } + // and rebuild indirect memberships: + $r = Subjects::_rebuildRels(); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } // fn removeSubjFromGr + + + /* --------------------------------------------------------- info methods */ + + /** + * Get subject id from login + * + * @param string $login + * @return int|PEAR_Error + */ + public static function GetSubjId($login) + { + global $CC_CONFIG; + global $CC_DBC; + $sql = "SELECT id FROM ".$CC_CONFIG['subjTable'] + ." WHERE login='$login'"; + return $CC_DBC->getOne($sql); + } // fn getSubjId + + + /** + * Get subject name (login) from id + * + * @param int $id + * @param string $fld + * @return string|PEAR_Error + */ + public static function GetSubjName($id, $fld='login') + { + global $CC_CONFIG; + global $CC_DBC; + $sql = "SELECT $fld FROM ".$CC_CONFIG['subjTable'] + ." WHERE id='$id'"; + return $CC_DBC->getOne($sql); + } // fn getSubjName + + + /** + * Get one subject from the table. + * + * @param string $p_fieldValue + * @param string $p_fieldName + * @return array + */ + public static function GetSubject($p_fieldValue, $p_fieldName='login') + { + global $CC_CONFIG, $CC_DBC; + if (!in_array($p_fieldName, array("login", "id"))) { + return null; + } + $escapedValue = pg_escape_string($p_fieldValue); + $sql = "SELECT * FROM ".$CC_CONFIG['subjTable'] + ." WHERE $p_fieldName='$escapedValue'"; + $row = $CC_DBC->GetRow($sql); + return $row; + } + + + /** + * Get all subjects + * + * @param string $flds + * @return array|PEAR_Error + */ + public static function GetSubjects($flds='id, login') + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT $flds FROM ".$CC_CONFIG['subjTable']; + return $CC_DBC->getAll($sql); + } // fn getSubjects + + + /** + * Get subjects with count of direct members + * + * @return array|PEAR_Error + */ + public static function GetSubjectsWCnt() + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT count(m.uid)as cnt, s.id, s.login, s.type" + ." FROM ".$CC_CONFIG['subjTable']." s" + ." LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=s.id" + ." WHERE m.mid is null" + ." GROUP BY s.id, s.login, s.type" + ." ORDER BY s.id"; + return $CC_DBC->getAll($sql); + } // fn getSubjectsWCnt + + + /** + * Return true if subject is a group + * + * @param int $gid + * @return boolean|PEAR_Error + */ + public static function IsGroup($gid) + { + global $CC_CONFIG, $CC_DBC; + if (empty($gid)) { + return FALSE; + } + $sql = "SELECT type FROM ".$CC_CONFIG['subjTable'] + ." WHERE id='$gid'"; + $r = $CC_DBC->getOne($sql); + if (PEAR::isError($r)) { + return $r; + } + return ($r === 'G'); + } // fn isGroup + + + /** + * List direct members of group + * + * @param int $gid + * @return array|PEAR_Error + */ + public static function ListGroup($gid) + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT s.id, s.login, s.type" + ." FROM ".$CC_CONFIG['smembTable']." m, ".$CC_CONFIG['subjTable']." s" + ." WHERE m.uid=s.id AND m.mid is null AND m.gid='$gid'"; + return $CC_DBC->getAll($sql); + } // fn listGroup + + + /** + * Return true if uid is [id]direct member of gid + * + * @param int $uid + * local user id + * @param int $gid + * local group id + * @return boolean + */ + public static function IsMemberOf($uid, $gid) + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT count(*)as cnt" + ." FROM ".$CC_CONFIG['smembTable'] + ." WHERE uid='$uid' AND gid='$gid'"; + $res = $CC_DBC->getOne($sql); + if (PEAR::isError($res)) { + return $res; + } + return (intval($res) > 0); + } // fn isMemberOf + + + /* ==================================================== "private" methods */ + + /** + * Create membership record + * + * @param int $uid + * @param int $gid + * @param int $level + * @param int $mid + * @return int|PEAR_Error + */ + private static function _addMemb($uid, $gid, $level=0, $mid='null') + { + global $CC_CONFIG, $CC_DBC; + if ($uid == $gid) { + return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB); + } + $sql = "SELECT id, level, mid FROM ".$CC_CONFIG['smembTable'] + ." WHERE uid='$uid' AND gid='$gid' ORDER BY level ASC"; + $a = $CC_DBC->getAll($sql); + if (PEAR::isError($a)) { + return $a; + } + if (count($a) > 0) { + $a0 = $a[0]; + $id = $a0['id']; + if ($level < intval($a0['level'])){ + $sql2 = "UPDATE ".$CC_CONFIG['smembTable'] + ." SET level='$level', mid=$mid WHERE id='{$a0['id']}'"; + $r = $CC_DBC->query($sql2); + if (PEAR::isError($r)) { + return $r; + } + } + } else { + $id = $CC_DBC->nextId($CC_CONFIG['smembSequence']); + if (PEAR::isError($id)) { + return $id; + } + $sql3 = "INSERT INTO ".$CC_CONFIG['smembTable']." (id, uid, gid, level, mid)" + ." VALUES ($id, $uid, $gid, $level, $mid)"; + $r = $CC_DBC->query($sql3); + if (PEAR::isError($r)) { + return $r; + } + } + return $id; + } // fn _addMemb + + + /** + * Remove membership record + * + * @param int $mid + * @return null|PEAR_Error + */ + private static function _removeMemb($mid) + { + global $CC_CONFIG, $CC_DBC; + $sql = "DELETE FROM ".$CC_CONFIG['smembTable'] + ." WHERE id='$mid'"; + return $CC_DBC->query($sql); + } // fn _removeMemb + + + /** + * List [in]direct members of group + * + * @param int $gid + * @param int $uid + * @return array|PEAR_Error + */ + private static function _listMemb($gid, $uid=NULL) + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT id, uid, level FROM ".$CC_CONFIG['smembTable'] + ." WHERE gid='$gid'".(is_null($uid) ? '' : " AND uid='$uid'"); + return $CC_DBC->getAll($sql); + } // fn _listMemb + + + /** + * List groups where uid is [in]direct member + * + * @param int $gid + * @param int $uid + * @return array|PEAR_Error + */ + private static function _listRMemb($uid, $gid=NULL) + { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT id, gid, level FROM ".$CC_CONFIG['smembTable'] + ." WHERE uid='$uid'".(is_null($gid) ? '' : " AND gid='$gid'"); + return $CC_DBC->getAll($sql); + } // fn listRMemb + + + /** + * Add uid and its [in]direct members to gid + * + * @param int $uid + * @param int $gid + * @param int $level + * @param int $rmid + * @return int|PEAR_Error + */ + private static function _plainAddSubjectToGroup($uid, $gid, $level=0, $rmid='null') + { + $mid = Subjects::_addMemb($uid, $gid, $level, $rmid); + if (PEAR::isError($mid)) { + return $mid; + } + $marr = Subjects::_listMemb($uid); + if (PEAR::isError($marr)) { + return $marr; + } + foreach ($marr as $k => $v) { + $r = Subjects::_addMemb( + $v['uid'], $gid, intval($v['level'])+$level+1, $mid + ); + if (PEAR::isError($r)) { + return $r; + } + } + return $mid; + } + + + /** + * Rebuild indirect membership records
+ * it's probably more complicated to do removing without rebuild ... + * + * @return true|PEAR_Error + */ + private static function _rebuildRels() + { + global $CC_CONFIG, $CC_DBC; + $CC_DBC->query("BEGIN"); + $r = $CC_DBC->query("LOCK TABLE ".$CC_CONFIG['smembTable']); + if (PEAR::isError($r)) { + return $r; + } + $sql = "DELETE FROM ".$CC_CONFIG['smembTable'] + ." WHERE mid is not null"; + $r = $CC_DBC->query($sql); + if (PEAR::isError($r)) { + return $r; + } + $arr = $CC_DBC->getAll("SELECT uid, gid FROM ".$CC_CONFIG['smembTable']); + // WHERE mid is null + if (PEAR::isError($arr)) { + return $arr; + } + foreach ($arr as $it) { + $marr = Subjects::_listRMemb($it['gid']); + if (PEAR::isError($marr)) { + return $marr; + } + foreach ($marr as $k => $v) { + $r = Subjects::_plainAddSubjectToGroup( + $it['uid'], $v['gid'], intval($v['level'])+1, $v['id'] + ); + if (PEAR::isError($r)) { + return $r; + } + } + } + $r = $CC_DBC->query("COMMIT"); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } // fn _rebuildRels + + + /* =============================================== test and debug methods */ + + /** + * Dump subjects for debug + * + * @param string $indstr + * indentation string + * @param string $ind + * actual indentation + * @return string + */ + public static function DumpSubjects($indstr=' ', $ind='') + { + $r = $ind.join(', ', array_map( + create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'), + Subjects::GetSubjectsWCnt() + ))."\n"; + return $r; + } // fn dumpSubjects + + + /** + * Delete all subjects and membership records + * + * @return void + */ + public static function DeleteData() + { + global $CC_CONFIG, $CC_DBC; + $CC_DBC->query("DELETE FROM ".$CC_CONFIG['subjTable']); + $CC_DBC->query("DELETE FROM ".$CC_CONFIG['smembTable']); + //ObjClasses::DeleteData(); + } // fn deleteData + + + /** + * Insert test data + * + * @return array + */ + public function TestData() + { +// $tdata = ObjClasses::TestData(); +// $o['root'] = Subjects::AddSubj('root', 'q'); +// $o['test1'] = Subjects::AddSubj('test1', 'a'); +// $o['test2'] = Subjects::AddSubj('test2', 'a'); +// $o['test3'] = Subjects::AddSubj('test3', 'a'); +// $o['test4'] = Subjects::AddSubj('test4', 'a'); +// $o['test5'] = Subjects::AddSubj('test5', 'a'); +// $o['gr1'] = Subjects::AddSubj('gr1'); +// $o['gr2'] = Subjects::AddSubj('gr2'); +// $o['gr3'] = Subjects::AddSubj('gr3'); +// $o['gr4'] = Subjects::AddSubj('gr4'); +// Subjects::AddSubjectToGroup('test1', 'gr1'); +// Subjects::AddSubjectToGroup('test2', 'gr2'); +// Subjects::AddSubjectToGroup('test3', 'gr3'); +// Subjects::AddSubjectToGroup('test4', 'gr4'); +// Subjects::AddSubjectToGroup('test5', 'gr1'); +// Subjects::AddSubjectToGroup('gr4', 'gr3'); +// Subjects::AddSubjectToGroup('gr3', 'gr2'); +// $tdata['subjects'] = $o; +// return $tdata; + } // fn TestData + + + /** + * Make basic test + * + */ + public static function Test() + { +// $p = ObjClasses::Test(); +// if (PEAR::isError($p)) { +// return $p; +// } +// Subjects::DeleteData(); +// Subjects::TestData(); +// $test_correct = "root(0), test1(0), test2(0), test3(0),". +// " test4(0), test5(0), gr1(2), gr2(2), gr3(2), gr4(1)\n"; +// $test_dump = Subjects::DumpSubjects(); +// Subjects::RemoveSubj('test1'); +// Subjects::RemoveSubj('test3'); +// Subjects::RemoveSubjectFromGroup('test5', 'gr1'); +// Subjects::RemoveSubjectFromGroup('gr3', 'gr2'); +// $test_correct .= "root(0), test2(0), test4(0), test5(0),". +// " gr1(0), gr2(1), gr3(1), gr4(1)\n"; +// $test_dump .= Subjects::DumpSubjects(); +// Subjects::DeleteData(); +// if ($test_dump == $test_correct) { +// $test_log .= "subj: OK\n"; +// return TRUE; +// } else { +// return PEAR::raiseError( +// 'Subjects::test:', 1, PEAR_ERROR_DIE, '%s'. +// "\ncorrect:\n{$test_correct}\n". +// "dump:\n{$test_dump}\n\n"); +// } + } // fn test + +} // class Subjects +?> \ No newline at end of file diff --git a/application/models/Transport.php b/application/models/Transport.php new file mode 100644 index 000000000..c5e8ce5dd --- /dev/null +++ b/application/models/Transport.php @@ -0,0 +1,1833 @@ + + * over unreliable network and from behind firewall
+ * + * Transport states: + *+ *
+ * + * Transport types: + *- init: transport is prepared, but not started + * (e.g. no network connection is present)
+ *- pending: transport is in progress, file is not fully transported to + * target system
+ *- waiting: transport is in progress, but not running now
+ *- finished: transport is finished, but file processing on target side + * is not completed
+ *- closed: processing on target side is completed without errors
+ *- failed: error - error message stored in errmsg field
+ *- paused: transport have been paused
+ *+ *
+ * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class Transport +{ + /** + * @var GreenBox + */ + public $gb; + + /** + * File name + * @var string + */ + private $cronJobScript; + + /** + * wget --read-timeout parameter [s] + * @var int + */ + private $downTimeout = 900; + + /** + * wget --waitretry parameter [s] + * @var int + */ + private $downWaitretry = 10; + + /** + * wget --limit-rate parameter + */ + private $downLimitRate = NULL; +# private $downLimitRate = 500; + + /** + * wget -t parameter + * @var int + */ + private $downRetries = 6; + + /** + * curl --max-time parameter + * @var int + */ + private $upTrMaxTime = 1800; + + /** + * curl --speed-time parameter + * @var int + */ + private $upTrSpeedTime = 30; + + /** + * curl --speed-limit parameter + * @var int + */ + private $upTrSpeedLimit = 30; + + /** + * curl --connect-timeout parameter + * @var int + */ + private $upTrConnectTimeout = 20; + + /** + * curl --limit-rate parameter + * @var int + */ + private $upLimitRate = NULL; +# private $upLimitRate = 500; + + + /** + * Constructor + * + * @param LocStor $gb + * @return Transport + */ + public function __construct(&$gb) + { + $this->gb =& $gb; + $this->cronJobScript = realpath( + dirname(__FILE__). + '/../../storageServer/var/cron/transportCronJob.php' + ); + } + + + /* ==================================================== transport methods */ + /* ------------------------------------------------------- common methods */ + /** + * Common "check" method for transports + * + * @param string $trtok + * transport token + * @return array + * struct/hasharray with fields: + * trtype: string - + * audioclip | playlist | playlistPkg | metadata | file + * state: string - transport state + * init | pending | waiting | finished | closed | failed + * direction: string - up | down + * expectedsize: int - file size in bytes + * realsize: int - currently transported bytes + * expectedsum: string - orginal file checksum + * realsum: string - transported file checksum + * title: string - dc:title or filename etc. + * errmsg: string - error message for failed transports + * ... ? + */ + function getTransportInfo($trtok) + { + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $res = array(); + foreach (array( + 'trtype', 'state', 'direction', 'expectedsize', 'realsize', + 'expectedsum', 'realsum', 'title', 'errmsg' + ) as $k) { + $res[$k] = ( isset($trec->row[$k]) ? $trec->row[$k] : NULL ); + } + if ( ($trec->row['direction'] == 'down') && file_exists($trec->row['localfile']) ){ + $res['realsize'] = filesize($trec->row['localfile']); + $res['realsum'] = $this->_chsum($trec->row['localfile']); + } + if ( ($trec->row['direction'] == 'up') ){ + $check = $this->uploadCheck($trec->row['pdtoken']); + if (!PEAR::isError($check)) { + $res['realsize'] = $check['size']; + $res['realsum'] = $check['realsum']; + } + } + return $res; + } + + + /** + * Turn transports on/off, optionaly return current state. + * (true=On / false=off) + * + * @param string $sessid + * session id + * @param boolean $onOff + * optional (if not used, current state is returned) + * @return boolea + * previous state + */ + function turnOnOffTransports($sessid, $onOff=NULL) + { + require_once('Prefs.php'); + $pr = new Prefs($this->gb); + $group = $CC_CONFIG['StationPrefsGr']; + $key = 'TransportsDenied'; + $res = $pr->loadGroupPref($group, $key); + if (PEAR::isError($res)) { + if ($res->getCode() !== GBERR_PREF) { + return $res; + } else { + $res = FALSE; // default + } + } + $state = !$res; + if (is_null($onOff)) { + return $state; + } + $res = $pr->saveGroupPref($sessid, $group, $key, !$onOff); + if (PEAR::isError($res)) { + return $res; + } + return $state; + } + + + /** + * Pause, resume or cancel transport + * + * @param string $trtok + * transport token + * @param string $action + * pause | resume | cancel + * @return string + * resulting transport state + */ + function doTransportAction($trtok, $action) + { + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + if ($trec->getState() == 'closed') { + return PEAR::raiseError( + "Transport::doTransportAction:". + " closed transport token ($trtok)", TRERR_TOK + ); + } + switch ($action) { + case 'pause'; + $newState = 'paused'; + break; + case 'resume'; + $newState = 'waiting'; + break; + case 'cancel'; + $newState = 'closed'; + break; + default: + return PEAR::raiseError( + "Transport::doTransportAction:". + " unknown action ($action)" + ); + } + $res = $trec->setState($newState); + switch ($action) { + case 'pause'; + case 'cancel'; + $trec->killJob(); + } + return $res; + } + + /* ------------- special methods for audioClip/webstream object transport */ + + /** + * Start upload of audioClip/webstream/playlist from local storageServer + * to hub. + * + * @param string $gunid + * global unique id of object being transported + * @param boolean $withContent + * if true, transport playlist content too (optional) + * @param array $pars + * default parameters (optional, internal use) + * @return string + * transport token + */ + function upload2Hub($gunid, $withContent=TRUE, $pars=array()) + { + global $CC_CONFIG, $CC_DBC; + $this->trLog("upload2Hub start: ".strftime("%H:%M:%S")); + switch ($ftype = BasicStor::GetType($gunid)) { + case "audioclip": + case "webstream": + $storedFile = StoredFile::RecallByGunid($gunid); + if (is_null($storedFile) || PEAR::isError($storedFile)) { + return $storedFile; + } + // handle metadata: + $mdfpath = $storedFile->getRealMetadataFileName(); + if (PEAR::isError($mdfpath)) { + return $mdfpath; + } + $mdtrec = $this->_uploadGeneralFileToHub($mdfpath, 'metadata', + array_merge(array('gunid'=>$gunid, 'fname'=>'metadata',), $pars) + ); + if (PEAR::isError($mdtrec)) { + return $mdtrec; + } + // handle raw media file: + $fpath = $storedFile->getRealFileName(); + if (PEAR::isError($fpath)) { + return $fpath; + } + $fname = $storedFile->getName(); + if (PEAR::isError($fname)) { + return $fname; + } + $trec = $this->_uploadGeneralFileToHub($fpath, 'audioclip', + array_merge(array( + 'gunid'=>$gunid, 'fname'=>$fname, 'mdtrtok'=>$mdtrec->trtok, + ), $pars) + ); + if (PEAR::isError($trec)) { + return $trec; + } + $this->startCronJobProcess($mdtrec->trtok); + break; + + case "playlist": + $plid = $gunid; + require_once("Playlist.php"); + $pl = StoredFile::RecallByGunid($plid); + if (is_null($pl) || PEAR::isError($pl)) { + return $pl; + } + $fname = $pl->getName(); + if (PEAR::isError($fname)) { + return $fname; + } + if ($withContent) { + $this->trLog("upload2Hub exportPlaylistOpen BEGIN: ".strftime("%H:%M:%S")); + $res = $this->gb->bsExportPlaylistOpen($plid); + $this->trLog("upload2Hub exportPlaylistOpen END: ".strftime("%H:%M:%S")); + if (PEAR::isError($res)) { + return $res; + } + $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_'); + $plfpath = "$tmpn.lspl"; + $this->trLog("upload2Hub begin copy: ".strftime("%H:%M:%S")); + copy($res['fname'], $plfpath); + $this->trLog("upload2Hub end copy: ".strftime("%H:%M:%S")); + $res = $this->gb->bsExportPlaylistClose($res['token']); + if (PEAR::isError($res)) { + return $res; + } + $fname = $fname.".lspl"; + $trtype = 'playlistPkg'; + } else { + $plfpath = $pl->getRealMetadataFileName(); + if (PEAR::isError($plfpath)) { + return $plfpath; + } + $trtype = 'playlist'; + } + $trec = $this->_uploadGeneralFileToHub($plfpath, $trtype, + array_merge(array('gunid'=>$plid,'fname'=>$fname,), $pars)); + if (PEAR::isError($trec)) { + return $trec; + } + break; + default: + return PEAR::raiseError("Transport::upload2Hub: ftype not supported ($ftype)"); + } + $this->startCronJobProcess($trec->trtok); + $this->trLog("upload2Hub end: ".strftime("%H:%M:%S")); + return $trec->trtok; + } + + + /** + * Start download of audioClip/webstream/playlist from hub to local + * storageServer + * + * @param int $uid + * local user id of transport owner + * (for downloading file to homedir in storage) + * @param string $gunid + * global unique id of object being transported + * @param boolean $withContent + * if true, transport playlist content too (optional) + * @param array $pars + * default parameters (optional, internal use) + * @return string + * transport token + */ + function downloadFromHub($uid, $gunid, $withContent=TRUE, $pars=array()) + { + $trtype = ($withContent ? 'playlistPkg' : 'unknown' ); + $trec = TransportRecord::create($this, $trtype, 'down', + array_merge(array('gunid'=>$gunid, 'uid'=>$uid), $pars)); + if (PEAR::isError($trec)) { + return $trec; + } + $this->startCronJobProcess($trec->trtok); + return $trec->trtok; + } + + + /* ------------------------------------------------ remote-search methods */ + /** + * Start search job on remote Campcaster instance. + * + * @param array $criteria + * LS criteria format (see localSearch) + * @param string $resultMode + * 'php' | 'xmlrpc' + * @param array $pars + * default parameters (optional, internal use) + * @return string + * transport token + */ + function remoteSearch($criteria, $resultMode='php') + { + global $CC_CONFIG, $CC_DBC; + $criteria['resultMode'] = $resultMode; + + // testing of hub availability and hub account configuration. + $sessid = $this->loginToArchive(); + if (PEAR::isError($sessid)) { + switch(intval($sessid->getCode())) { + case 802: + return PEAR::raiseError("Can't login to Hub ({$sessid->getMessage()})", TRERR_XR_FAIL); + case TRERR_XR_FAIL: + return PEAR::raiseError("Can't connect to Hub ({$sessid->getMessage()})", TRERR_XR_FAIL); + } + return $sessid; + } + $params = array("sessid" => $sessid, "criteria" => $criteria); + $result = $this->xmlrpcCall("locstor.searchMetadata", $params); + //$result = $this->xmlrpcCall("locstor.ping", array("par" => "foo")); + $this->logoutFromArchive($sessid); + return $result; + } + + /** + * Start search job on network hub + * + * @param array $criteria + * LS criteria format (see localSearch) + * @param string $resultMode + * 'php' | 'xmlrpc' + * @param array $pars + * default parameters (optional, internal use) + * @return string + * transport token + */ +// function globalSearch($criteria, $resultMode='php', $pars=array()) +// { +// global $CC_CONFIG, $CC_DBC; +// // testing of hub availability and hub account configuration. +// // it makes searchjob not async - should be removed for real async +// $r = $this->loginToArchive(); +// if (PEAR::isError($r)) { +// switch(intval($r->getCode())) { +// case 802: +// return PEAR::raiseError("Can't login to Hub ({$r->getMessage()})", TRERR_XR_FAIL); +// case TRERR_XR_FAIL: +// return PEAR::raiseError("Can't connect to Hub ({$r->getMessage()})", TRERR_XR_FAIL); +// } +// return $r; +// } +// $this->logoutFromArchive($r); +// $criteria['resultMode'] = $resultMode; +// $localfile = tempnam($CC_CONFIG['transDir'], 'searchjob_'); +// @chmod($localfile, 0660); +// $len = file_put_contents($localfile, serialize($criteria)); +// $trec = $this->_uploadGeneralFileToHub($localfile, 'searchjob', $pars); +// if (PEAR::isError($trec)) { +// return $trec; +// } +// $this->startCronJobProcess($trec->trtok); +// return $trec->trtok; +// } + + + /** + * Get results from search job on network hub + * + * @param string $trtok + * transport token + * @param boolean $andClose + * if TRUE, close transport token + * @return array + * LS search result format (see localSearch) + */ +// function getSearchResults($trtok, $andClose=TRUE) +// { +// $trec = TransportRecord::recall($this, $trtok); +// if (PEAR::isError($trec)) { +// return $trec; +// } +// $row = $trec->row; +// switch ($st = $trec->getState()) { +// case "failed": +// return PEAR::raiseError( +// "Transport::getSearchResults:". +// " global search or results transport failed". +// " ({$trec->row['errmsg']})" +// ); +// case "closed": +///* +// $res = file_get_contents($row['localfile']); +// $results = unserialize($res); +// return $results; +//*/ +// return PEAR::raiseError( +// "Transport::getSearchResults:". +// " closed transport token ($trtok)", TRERR_TOK +// ); +// case "finished": +// if ($row['direction'] == 'down') { +// // really finished +// $res = file_get_contents($row['localfile']); +// $results = unserialize($res); +// if ($andClose) { +// $ret = $this->xmlrpcCall('archive.downloadClose', +// array( +// 'token' => $row['pdtoken'] , +// 'trtype' => $row['trtype'] , +// )); +// if (PEAR::isError($ret)) { +// return $ret; +// } +// @unlink($row['localfile']); +// $r = $trec->close(); +// if (PEAR::isError($r)) { +// return $r; +// } +// } +// return $results; +// } +// // otherwise not really finished - only request upload finished +// default: +// return PEAR::raiseError( +// "Transport::getSearchResults: not finished ($st)", +// TRERR_NOTFIN +// ); +// } +// } + + + /* ------------------------ methods for ls-archive-format file transports */ + /** + * Open async file transfer from local storageServer to network hub, + * file should be ls-archive-format file. + * + * @param string $filePath + * local path to uploaded file + * @param array $pars + * default parameters (optional, internal use) + * @return string + * transport token + */ + function uploadFile2Hub($filePath, $pars=array()) + { + if (!file_exists($filePath)) { + return PEAR::raiseError( + "Transport::uploadFile2Hub: file not found ($filePath)" + ); + } + $trec = $this->_uploadGeneralFileToHub($filePath, 'file', $pars); + if (PEAR::isError($trec)) { + return $trec; + } + $this->startCronJobProcess($trec->trtok); + return $trec->trtok; + } + + + /** + * Open async file transfer from network hub to local storageServer, + * file should be ls-archive-format file. + * + * @param string $url + * readable url + * @param string $chsum + * checksum from remote side + * @param int $size + * filesize from remote side + * @param array $pars + * default parameters (internal use) + * @return array + * trtok: string - transport token + * localfile: string - filepath of downloaded file + */ + function downloadFileFromHub($url, $chsum=NULL, $size=NULL, $pars=array()) + { + global $CC_CONFIG, $CC_DBC; + $tmpn = tempnam($CC_CONFIG['transDir'], 'HITrans_'); + $trec = TransportRecord::create($this, 'file', 'down', + array_merge(array( + 'url' => $url, + 'localfile' => $tmpn, + 'expectedsum' => $chsum, + 'expectedsize' => $size, + ), $pars) + ); + if (PEAR::isError($trec)) { + return $trec; + } + $this->startCronJobProcess($trec->trtok); + return array('trtok'=>$trec->trtok, 'localfile'=>$tmpn); + } + + + /** + * Get list of prepared transfers initiated by hub + * + * @return array + * array of structs/hasharrays with fields: + * trtok: string transport token + */ + function getHubInitiatedTransfers() + { + $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers', + array('target' => HOSTNAME)); + if (PEAR::isError($ret)) { + return $ret; + } + $res = array(); + foreach ($ret as $it) { + $res[] = array('trtok'=>$it['trtok']); + } + return $res; + } + + + /** + * Start of download initiated by hub + * + * @param int $uid + * local user id of transport owner + * (for downloading file to homedir in storage) + * @param string $rtrtok + * transport token obtained from the getHubInitiatedTransfers method + * @return string + * transport token + */ + function startHubInitiatedTransfer($uid, $rtrtok) + { + $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers', + array( + 'target' => HOSTNAME, + 'trtok' => $rtrtok, + )); + if (PEAR::isError($ret)) { + return $ret; + } + if (count($ret) != 1) { + return PEAR::raiseError( + "Transport::startHubInitiatedTransfer:". + " wrong number of transports (".count($ret).")" + ); + } + $ta = $ret[0]; + // direction invertation to locstor point of view: + $direction = ( $ta['direction']=='up' ? 'down' : 'up' ); + $gunid = $ta['gunid']; + switch ($direction) { + case "up": + switch ($ta['trtype']) { + case "audioclip": + case "playlist": + case "playlistPkg": + $trtok = $this->upload2Hub($gunid, TRUE, + array('rtrtok'=>$rtrtok)); + if (PEAR::isError($trtok)) { + return $trtok; + } + break; + //case "searchjob": break; // not supported yet + //case "file": break; // probably unusable + default: + return PEAR::raiseError( + "Transport::startHubInitiatedTransfer:". + " wrong direction / transport type combination". + " ({$ta['direction']}/{$ta['trtype']})" + ); + } + break; + case "down": + switch ($ta['trtype']) { + case "audioclip": + case "playlist": + case "playlistPkg": + $trtok = $this->downloadFromHub($uid, $gunid, TRUE, + array('rtrtok'=>$rtrtok)); + if (PEAR::isError($trtok)) { + return $trtok; + } + break; + //case "searchjob": break; // probably unusable + case "file": + $r = $this->downloadFileFromHub( + $ta['url'], $ta['expectedsum'], $ta['expectedsize'], + array('rtrtok'=>$rtrtok)); + if (PEAR::isError($r)) { + return $r; + } + extract($r); // trtok, localfile + break; + default: + return PEAR::raiseError( + "Transport::startHubInitiatedTransfer:". + " wrong direction / transport type combination". + " ({$ta['direction']}/{$ta['trtype']})" + ); + } + break; + default: + return PEAR::raiseError( + "Transport::startHubInitiatedTransfer: ???" + ); + } + $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer', + array( + 'target' => HOSTNAME, + 'trtok' => $rtrtok, + 'state' => 'waiting', + )); + if (PEAR::isError($ret)) { + return $ret; + } + $this->startCronJobProcess($trtok); + return $trtok; + } + + + /* =============================================== authentication methods */ + + /** + * Login to archive server + * (account info is taken from storageServer's config) + * + * @return string + * sessid or error + */ + function loginToArchive() + { + global $CC_CONFIG; + $res = $this->xmlrpcCall('locstor.login', + array( + 'login' => $CC_CONFIG['archiveAccountLogin'], + 'pass' => $CC_CONFIG['archiveAccountPass'] + )); + if (PEAR::isError($res)) { + return $res; + } + return $res['sessid']; + } + + + /** + * Logout from archive server + * + * @param unknown $sessid + * session id + * @return string + * Bye or error + */ + function logoutFromArchive($sessid) + { + $res = $this->xmlrpcCall('locstor.logout', + array('sessid'=>$sessid)); + return $res; + } + + + /* ========================================================= cron methods */ + /* -------------------------------------------------- common cron methods */ + /** + * Main method for periodical transport tasks - called by cron + * + * @param string $direction + * optional + * @return boolean + * TRUE + */ + function cronMain($direction=NULL) + { + global $CC_CONFIG; + if (is_null($direction)) { + $r = $this->cronMain('up'); + if (PEAR::isError($r)) { + return $r; + } + $r = $this->cronMain('down'); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + // fetch all opened transports + $transports = $this->getTransports($direction); + if (PEAR::isError($transports)) { + $this->trLog("cronMain: DB error"); + return FALSE; + } + if (count($transports) == 0) { + if (TR_LOG_LEVEL > 1) { + $this->trLog("cronMain: $direction - nothing to do."); + } + return TRUE; + } + // ping to archive server: + $r = $this->ping(); + chdir($CC_CONFIG['transDir']); + // for all opened transports: + foreach ($transports as $i => $row) { + $r = $this->startCronJobProcess($row['trtok']); + } // foreach transports + return TRUE; + } + + + /** + * Cron job process starter + * + * @param string $trtok + * transport token + * @return boolean + * status + */ + function startCronJobProcess($trtok) + { + global $CC_CONFIG, $CC_DBC; + if (TR_LOG_LEVEL > 2) { + $redirect = $CC_CONFIG['transDir']."/debug.log"; + } else { + $redirect = "/dev/null"; + } + $redirect_escaped = escapeshellcmd($redirect); + $command = "{$this->cronJobScript} {$trtok}"; + $command_escaped = escapeshellcmd($command); + $command_final = "$command_escaped >> $redirect_escaped 2>&1 &"; + $res = system($command_final, $status); + if ($res === FALSE) { + $this->trLog( + "cronMain: Error on execute cronJobScript with trtok {$trtok}" + ); + return FALSE; + } + return TRUE; + } + + + /** + * Dynamic method caller - wrapper + * + * @param string $trtok + * transport token + * @return mixed + * inherited from called method + */ + function cronCallMethod($trtok) + { + global $CC_CONFIG; + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $row = $trec->row; + $state = $row['state']; + + $states = array('init'=>'init', + 'pending'=>'pending', + 'waiting'=>'waiting', + 'finished'=>'finished', + 'failed'=>'failed', + 'closed'=>'closed'); + $directions = array('up'=>'upload', 'down'=>'download'); + // method name construction: + $mname = "cron"; + if (isset($directions[$row['direction']])) { + $mname .= ucfirst($directions[$row['direction']]); + } else { + return PEAR::raiseError( + "Transport::cronCallMethod: invalid direction ({$row['direction']})" + ); + } + if (isset($states[$state])) { + $mname .= ucfirst($states[$state]); + } else { + return PEAR::raiseError( + "Transport::cronCallMethod: invalid state ({$state})" + ); + } + switch ($state) { + // do nothing if closed, penfing or failed: + case 'closed': // excluded in SQL query too, but let check it here + case 'failed': // -"- + case 'pending': + case 'paused': + return TRUE; + case 'waiting': + require_once('Prefs.php'); + $pr = new Prefs($this->gb); + $group = $CC_CONFIG['StationPrefsGr']; + $key = 'TransportsDenied'; + $res = $pr->loadGroupPref($group, $key); + if (PEAR::isError($res)) { + if ($res->getCode() !== GBERR_PREF) { + return $res; + } else { + $res = FALSE; // default + } + } + // transfers turned off + // if ($res) { return TRUE; break; } + if ($res) { + return PEAR::raiseError( + "Transport::cronCallMethod: transfers turned off" + ); + } + // NO break here! + default: + if (method_exists($this, $mname)) { + // lock the job: + $pid = getmypid(); + $r = $trec->setLock(TRUE, $pid); + if (PEAR::isError($r)) { + return $r; + } + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + $trec->setLock(FALSE); + return $trec; + } + $row = $trec->row; + $state = $row['state']; + + // login to archive server: + $r = $this->loginToArchive(); + if (PEAR::isError($r)) { + $r2 = $trec->setLock(FALSE); + return $r; + } + $asessid = $r; + // method call: + if (TR_LOG_LEVEL > 2) { + $this->trLog("cronCallMethod($pid): $mname($trtok) >"); + } + $ret = call_user_func(array($this, $mname), $row, $asessid); + if (PEAR::isError($ret)) { + $trec->setLock(FALSE); + return $this->_failFatal($ret, $trec); + } + if (TR_LOG_LEVEL > 2) { + $this->trLog("cronCallMethod($pid): $mname($trtok) <"); + } + // unlock the job: + $r = $trec->setLock(FALSE); + if (PEAR::isError($r)) { + return $r; + } + // logout: + $r = $this->logoutFromArchive($asessid); + if (PEAR::isError($r)) { + return $r; + } + return $ret; + } else { + return PEAR::raiseError( + "Transport::cronCallMethod: unknown method ($mname)" + ); + } + } + } + + + /** + * Upload initialization + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronUploadInit($row, $asessid) + { + $trtok = $row['trtok']; + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $ret = $this->xmlrpcCall('archive.uploadOpen', + array( + 'sessid' => $asessid , + 'chsum' => $row['expectedsum'], + )); + if (PEAR::isError($ret)) { + return $ret; + } + $r = $trec->setState('waiting', + array('url'=>$ret['url'], 'pdtoken'=>$ret['token'])); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /** + * Download initialization + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronDownloadInit($row, $asessid) + { + global $CC_CONFIG; + $trtok = $row['trtok']; + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $ret = $this->xmlrpcCall('archive.downloadOpen', + array( + 'sessid'=> $asessid, + 'trtype'=> $row['trtype'], + 'pars'=>array( + 'gunid' => $row['gunid'], + 'token' => $row['pdtoken'], + ), + )); + if (PEAR::isError($ret)) { + return $ret; + } + $trtype = $ret['trtype']; + $title = $ret['title']; + $pars = array(); + switch ($trtype) { +// case "searchjob": +// $r = $trec->setState('waiting', $pars); +// break; + case "file": + $r = $trec->setState('waiting',array_merge($pars, array( + 'trtype'=>$trtype, + 'url'=>$ret['url'], 'pdtoken'=>$ret['token'], + 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'], + 'fname'=>$ret['filename'], + 'localfile'=>$CC_CONFIG['transDir']."/$trtok", + ))); + break; + case "audioclip": + $mdtrec = TransportRecord::create($this, 'metadata', 'down', + array('gunid'=>$row['gunid'], 'uid'=>$row['uid'], ) + ); + if (PEAR::isError($mdtrec)) { + return $mdtrec; + } + $this->startCronJobProcess($mdtrec->trtok); + $pars = array('mdtrtok'=>$mdtrec->trtok); + // NO break here ! + default: + $r = $trec->setState('waiting',array_merge($pars, array( + 'trtype'=>$trtype, + 'url'=>$ret['url'], 'pdtoken'=>$ret['token'], + 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'], + 'fname'=>$ret['filename'], 'title'=>$title, + 'localfile'=>$CC_CONFIG['transDir']."/$trtok", + ))); + } + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /** + * Upload next part of transported file + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronUploadWaiting($row, $asessid) + { + $trtok = $row['trtok']; + $check = $this->uploadCheck($row['pdtoken']); + if (PEAR::isError($check)) { + return $check; + } + // test filesize + if (!file_exists($row['localfile'])) { + return PEAR::raiseError("Transport::cronUploadWaiting:". + " file being uploaded does not exist! ({$row['localfile']})" + ); + } + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $size = escapeshellarg($check['size']); + $localfile = escapeshellarg($row['localfile']); + $url = escapeshellarg($row['url']); + $command = + "curl -f -s -C $size --max-time {$this->upTrMaxTime}". + " --speed-time {$this->upTrSpeedTime}". + " --speed-limit {$this->upTrSpeedLimit}". + " --connect-timeout {$this->upTrConnectTimeout}". + (!is_null($this->upLimitRate)? + " --limit-rate {$this->upLimitRate}" : ""). + " -T $localfile $url"; + $r = $trec->setState('pending', array(), 'waiting'); + if (PEAR::isError($r)) { + return $r; + } + if ($r === FALSE) { + return TRUE; + } + $res = system($command, $status); + + // leave paused and closed transports + $trec2 = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $state2 = $trec2->row['state']; + if ($state2 == 'paused' || $state2 == 'closed' ) { + return TRUE; + } + + + // status 18 - Partial file. Only a part of the file was transported. + // status 28 - Timeout. Too long/slow upload, try to resume next time rather. + // status 6 - Couldn't resolve host. + // status 7 - Failed to connect to host. + // status 56 - Failure in receiving network data. Important - this status is + // returned if file is locked on server side + if ($status == 0 || $status == 18 || $status == 28 || $status == 6 || $status == 7 || $status == 56) { + $check = $this->uploadCheck($row['pdtoken']); + if (PEAR::isError($check)) { + return $check; + } + // test checksum + if ($check['status'] == TRUE) { + // finished + $r = $trec->setState('finished', + array('realsum'=>$check['realsum'], 'realsize'=>$check['size'])); + if (PEAR::isError($r)) { + return $r; + } + } else { + if (intval($check['size']) < $row['expectedsize']) { + $r = $trec->setState('waiting', + array('realsum'=>$check['realsum'], 'realsize'=>$check['size'])); + if (PEAR::isError($r)) { + return $r; + } + } else { + // wrong md5 at finish - TODO: start again + // $this->xmlrpcCall('archive.uploadReset', array()); + $trec->fail('file uploaded with bad md5'); + return PEAR::raiseError("Transport::cronUploadWaiting:". + " file uploaded with bad md5 ". + "($trtok: {$check['realsum']}/{$check['expectedsum']})" + ); + } + } + } else { + return PEAR::raiseError("Transport::cronUploadWaiting:". + " wrong return status from curl: $status on $url". + "($trtok)" + ); + } + return TRUE; + } + + + /** + * Download next part of transported file + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronDownloadWaiting($row, $asessid) + { + $trtok = $row['trtok']; + // wget the file + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $localfile = escapeshellarg($row['localfile']); + $url = escapeshellarg($row['url']); + $command = + "wget -q -c". + " --read-timeout={$this->downTimeout}". + " --waitretry={$this->downWaitretry}". + " -t {$this->downRetries}". + (!is_null($this->downLimitRate)? + " --limit-rate={$this->downLimitRate}" : ""). + " -O $localfile $url" + ; + $r = $trec->setState('pending', array(), 'waiting'); + if (PEAR::isError($r)) { + return $r; + } + if ($r === FALSE) { + return TRUE; + } + $res = system($command, $status); + + // leave paused and closed transports + $trec2 = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $state2 = $trec2->row['state']; + if ($state2 == 'paused' || $state2 == 'closed' ) { + return TRUE; + } + + // check consistency + $size = filesize($row['localfile']); + if ($size < $row['expectedsize']) { + // not finished - return to the 'waiting' state + $r = $trec->setState('waiting', array('realsize'=>$size)); + if (PEAR::isError($r)) { + return $r; + } + } elseif ($size >= $row['expectedsize']) { + $chsum = $this->_chsum($row['localfile']); + if ($chsum == $row['expectedsum']) { + // mark download as finished + $r = $trec->setState('finished', + array('realsum'=>$chsum, 'realsize'=>$size)); + if (PEAR::isError($r)) { + return $r; + } + } else { + // bad checksum, retry from the scratch + @unlink($row['localfile']); + $r = $trec->setState('waiting', + array('realsum'=>$chsum, 'realsize'=>$size)); + if (PEAR::isError($r)) { + return $r; + } + } + } + return TRUE; + } + + + /** + * Finish the upload + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronUploadFinished($row, $asessid) + { + global $CC_CONFIG; + $trtok = $row['trtok']; + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + // don't close metadata transport - audioclip will close it + if ($row['trtype'] == 'metadata') { + return TRUE; + } + // handle metadata transport on audioclip trtype: + if ($row['trtype'] == 'audioclip') { + $mdtrec = TransportRecord::recall($this, $trec->row['mdtrtok']); + if (PEAR::isError($mdtrec)) { + return $mdtrec; + } + switch ($mdtrec->row['state']) { + case 'failed': + case 'closed': + return PEAR::raiseError("Transport::cronUploadFinished:". + " metadata transport in wrong state: {$mdtrec->row['state']}". + " ({$this->trtok})" + ); + break; + // don't close transport with nonfinished metadata transport: + case 'init': + case 'waiting': + case 'pending': + case 'paused': + return TRUE; + default: // finished - ok close parent transport + $mdpdtoken = $mdtrec->row['pdtoken']; + } + } else { + $mdpdtoken = NULL; + } + $ret = $this->xmlrpcCall('archive.uploadClose', + array( + 'token' => $row['pdtoken'] , + 'trtype' => $row['trtype'], + 'pars' => array( + 'gunid' => $row['gunid'], + 'name' => $row['fname'], + 'mdpdtoken' => $mdpdtoken, + ), + )); + if (PEAR::isError($ret)) { + if ($row['trtype'] == 'audioclip') { + $r2 = $mdtrec->close(); + } + return $ret; + } + +// if ($row['trtype'] == 'searchjob') { +// @unlink($row['localfile']); +// $r = $trec->setState('init', array( +// 'direction' => 'down', +// 'pdtoken' => $ret['token'], +// 'expectedsum' => $ret['chsum'], +// 'expectedsize' => $ret['size'], +// 'url' => $ret['url'], +// 'realsize' => 0, +// )); +// $this->startCronJobProcess($trec->trtok); +// } else { + $r = $trec->close(); +// } + if (PEAR::isError($r)) { + return $r; + } + switch ($row['trtype']) { + case 'audioclip': + // close metadata transport: + $r = $mdtrec->close(); + if (PEAR::isError($r)) { + return $r; + } + break; + case 'playlistPkg': + // remove exported playlist (playlist with content) + $ep = $row['localfile']; + @unlink($ep); + if (preg_match("|/(plExport_[^\.]+)\.lspl$|", $ep, $va)) { + list(,$tmpn) = $va; $tmpn = $CC_CONFIG['transDir']."/$tmpn"; + if (file_exists($tmpn)) { + @unlink($tmpn); + } + } + + break; + default: + } + + return TRUE; + } + + + /** + * Finish the download + * + * @param array $row + * row from getTransport results + * @param string $asessid + * session id (from network hub) + * @return mixed + * boolean TRUE or error object + */ + function cronDownloadFinished($row, $asessid) + { + $trtok = $row['trtok']; + $trec = TransportRecord::recall($this, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + switch ($row['trtype']) { + case "audioclip": + $mdtrtok = $trec->row['mdtrtok']; + $mdtrec = TransportRecord::recall($this, $mdtrtok); + if (PEAR::isError($mdtrec)) { + return $mdtrec; + } + $pid = getmypid(); + $r = $mdtrec->setLock(TRUE, $pid); + if (PEAR::isError($r)) { + return $r; + } + switch ($mdtrec->row['state']) { + // don't close transport with nonfinished metadata transport: + case 'init': + case 'waiting': + case 'pending': + case 'paused': + $r = $mdtrec->setLock(FALSE); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + case 'finished': // metadata finished, close main transport + $values = array( + "filename" => $row['fname'], + "filepath" => $trec->row['localfile'], + "metadata" => $mdtrec->row['localfile'], + "gunid" => $row['gunid'], + "filetype" => "audioclip" + ); + $storedFile = StoredFile::Insert($values); + if (PEAR::isError($storedFile)) { + $mdtrec->setLock(FALSE); + return $storedFile; + } + $res = $storedFile->getId(); + $ret = $this->xmlrpcCall('archive.downloadClose', + array( + 'token' => $mdtrec->row['pdtoken'] , + 'trtype' => 'metadata' , + )); + if (PEAR::isError($ret)) { + $mdtrec->setLock(FALSE); + return $ret; + } + $r = $mdtrec->close(); + if (PEAR::isError($r)) { + $r2 = $mdtrec->setLock(FALSE); + return $r; + } + @unlink($trec->row['localfile']); + @unlink($mdtrec->row['localfile']); + break; + default: + $r = $mdtrec->setLock(FALSE); + return PEAR::raiseError("Transport::cronDownloadFinished:". + " metadata transport in wrong state: {$mdtrec->row['state']}". + " ({$this->trtok})" + ); + } + $r = $mdtrec->setLock(FALSE); + if (PEAR::isError($r)) { + return $r; + } + break; + case "metadata": +// case "searchjob": + return TRUE; // don't close - getSearchResults should close it + break; + } + $ret = $this->xmlrpcCall('archive.downloadClose', + array( + 'token' => $row['pdtoken'] , + 'trtype' => $row['trtype'] , + )); + if (PEAR::isError($ret)) { + return $ret; + } + switch ($row['trtype']) { + case "playlist": + $values = array( + "filename" => $row['fname'], + "metadata" => $trec->row['localfile'], + "gunid" => $row['gunid'], + "filetype" => "playlist" + ); + $storedFile = StoredFile::Insert($values); + if (PEAR::isError($storedFile)) { + return $storedFile; + } + $res = $storedFile->getId(); + @unlink($row['localfile']); + break; + case "playlistPkg": + $subjid = $trec->row['uid']; + $fname = $trec->row['localfile']; + $res = $this->gb->bsImportPlaylist($fname, $subjid); + if (PEAR::isError($res)) { + return $res; + } + @unlink($fname); + break; + case "audioclip": + case "metadata": +// case "searchjob": + case "file": + break; + default: + return PEAR::raiseError("DEBUG: NotImpl ".var_export($row,TRUE)); + } + if (!is_null($rtrtok = $trec->row['rtrtok'])) { + $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer', + array( + 'target' => HOSTNAME, + 'trtok' => $rtrtok, + 'state' => 'closed', + )); + if (PEAR::isError($ret)) { + return $ret; + } + } + $r = $trec->close(); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /* ==================================================== auxiliary methods */ + /** + * Prepare upload for general file + * + * @param string $fpath + * local filepath of uploaded file + * @param string $trtype + * transport type + * @param array $pars + * default parameters (optional, internal use) + * @return object - transportRecord instance + */ + function _uploadGeneralFileToHub($fpath, $trtype, $pars=array()) + { + $chsum = $this->_chsum($fpath); + $size = filesize($fpath); + $trec = TransportRecord::create($this, $trtype, 'up', + array_merge(array( + 'localfile'=>$fpath, 'fname'=>basename($fpath), + 'expectedsum'=>$chsum, 'expectedsize'=>$size + ), $pars) + ); + if (PEAR::isError($trec)) { + return $trec; + } + return $trec; + } + + + /** + * Create new transport token + * + * @return string + * transport token + */ + function _createTransportToken() + { + $ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''); + $initString = microtime().$ip.rand()."org.mdlf.campcaster"; + $hash = md5($initString); + $res = substr($hash, 0, 16); + return $res; + } + + + /** + * Get all relevant transport records + * + * @param string $direction + * 'up' | 'down' + * @param string $target + * target hostname + * @param string $trtok + * transport token for specific query + * @return array + * array of transportRecords (as hasharrays) + */ + function getTransports($direction=NULL, $target=NULL, $trtok=NULL) + { + global $CC_CONFIG, $CC_DBC; + switch ($direction) { + case 'up': + $dirCond = "direction='up' AND"; + break; + case 'down': + $dirCond = "direction='down' AND"; + break; + default: + $dirCond = ''; + break; + } + if (is_null($target)) { + $targetCond = ""; + } else { + $targetCond = "target='$target' AND"; + } + if (is_null($trtok)) { + $trtokCond = ""; + } else { + $trtokCond = "trtok='$trtok' AND"; + } + $rows = $CC_DBC->getAll(" + SELECT + id, trtok, state, trtype, direction, + to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken, + fname, localfile, expectedsum, expectedsize, url, + uid, target + FROM ".$CC_CONFIG['transTable']." + WHERE $dirCond $targetCond $trtokCond + state not in ('closed', 'failed', 'paused') + ORDER BY start DESC + "); + if (PEAR::isError($rows)) { + return $rows; + } + foreach ($rows as $i => $row) { + $rows[$i]['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']); + $rows[$i]['gunid'] = StoredFile::NormalizeGunid($row['gunid']); + } + return $rows; + } + + + /** + * Check remote state of uploaded file + * + * @param string $pdtoken + * put/download token (from network hub) + * @return array + * hash: chsum, size, url + */ + function uploadCheck($pdtoken) + { + $ret = $this->xmlrpcCall('archive.uploadCheck', + array('token'=>$pdtoken)); + return $ret; + } + + + /** + * Ping to remote Campcaster server + * + * @return string + * network hub response or error object + */ + function ping() + { + $res = $this->xmlrpcCall('ping', + array('par'=>'ping_'.date('H:i:s'))); + return $res; + } + + + /** + * XMLRPC call to network hub. + * + * @param string $method + * method name + * @param array $pars + * call parameters + * @return mixed + * response + */ + function xmlrpcCall($method, $pars=array()) + { + global $CC_CONFIG; + $xrp = XML_RPC_encode($pars); + + $pr = new Prefs($this->gb); + $group = $CC_CONFIG["StationPrefsGr"]; + $key = 'archiveServerLocation'; + $archiveUrl = $pr->loadGroupPref($group, $key, false); + + if ($archiveUrl) { + $archiveUrlInfo = parse_url($archiveUrl); + if ($archiveUrlInfo['port']) { + $port = $archiveUrlInfo['port']; + } + else { + $port = 80; + } + + $c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port); + } + else { + $c = new XML_RPC_Client( + $CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'], + $CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort'] + ); + } + + $f = new XML_RPC_Message($method, array($xrp)); + $r = $c->send($f); + if (!$r) { + return PEAR::raiseError("XML-RPC request failed", TRERR_XR_FAIL); + } elseif ($r->faultCode() > 0) { + return PEAR::raiseError($r->faultString(), $r->faultCode()); + // return PEAR::raiseError($r->faultString(). + // " (code ".$r->faultCode().")", TRERR_XR_FAIL); + } else { + $v = $r->value(); + return XML_RPC_decode($v); + } + } + + + /** + * Checksum of local file + * + * @param string $fpath + * local filepath + * @return string + * checksum + */ + function _chsum($fpath) + { + return md5_file($fpath); + } + + + /** + * Check exception and eventually mark transport as failed + * + * @param mixed $res + * result object to be checked + * @param unknown $trec + * transport record object + * @return unknown + */ + function _failFatal($res, $trec) + { + if (PEAR::isError($res)) { + switch ($res->getCode()) { + // non fatal: + case TRERR_XR_FAIL: + break; + // fatal: + default: + $trec->fail('', $res); + } + } + return $res; + } + + + /** + * Clean up transport jobs + * + * @param string $interval + * psql time interval - older closed jobs will be deleted + * @param boolean $forced + * if true, delete non-closed jobs too + * @return boolean true or error + */ + function _cleanUp($interval='1 minute'/*'1 hour'*/, $forced=FALSE) + { + global $CC_CONFIG, $CC_DBC; + $cond = ($forced ? '' : " AND state='closed' AND lock = 'N'"); + $r = $CC_DBC->query(" + DELETE FROM ".$CC_CONFIG['transTable']." + WHERE ts < now() - interval '$interval'".$cond + ); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /** + * Logging wrapper for PEAR error object + * + * @param string $txt + * log message + * @param PEAR_Error $eo + * @param array $row + * array returned from getRow + * @return mixed + * void or error object + */ + function trLogPear($txt, $eo, $row=NULL) + { + $msg = $txt.$eo->getMessage()." ".$eo->getUserInfo(). + " [".$eo->getCode()."]"; + if (!is_null($row)) { + $trec = TransportRecord::recall($this, $row['trtok']); + if (!PEAR::isError($trec)) { + $trec->setState('failed', array('errmsg'=>$msg)); + } + $msg .= "\n ".serialize($row); + } + $this->trLog($msg); + } + + + /** + * Logging for debug transports + * + * @param string $msg + * log message + * @return mixed + * void or error object + */ + function trLog($msg) + { + global $CC_CONFIG; + $logfile = $CC_CONFIG['transDir']."/activity.log"; + if (FALSE === ($fp = fopen($logfile, "a"))) { + return PEAR::raiseError( + "Transport::trLog: Can't write to log ($logfile)" + ); + } + flock($fp,LOCK_SH); + fputs($fp, "---".date("H:i:s")."---\n $msg\n"); + flock($fp,LOCK_UN); + fclose($fp); + } + + + /* ====================================================== install methods */ + /** + * Delete all transports + * + * @return mixed + * void or error object + */ + function resetData() + { + global $CC_CONFIG, $CC_DBC; + return $CC_DBC->query("DELETE FROM ".$CC_CONFIG['transTable']); + } + +} + +?> diff --git a/application/models/TransportRecord.php b/application/models/TransportRecord.php new file mode 100644 index 000000000..9a491e7eb --- /dev/null +++ b/application/models/TransportRecord.php @@ -0,0 +1,419 @@ +tr =& $tr; + $this->gb =& $tr->gb; + } + + + /** + * Factory method + * + * @param Transport $tr + * @param string $trtype + * transport type (see Transport::install) + * @param string $direction + * 'up' | 'down' + * @param array $defaults + * default parameters (optional, internal use) + * @return TransportRecord + */ + function create(&$tr, $trtype, $direction='up', $defaults=array()) + { + global $CC_DBC, $CC_CONFIG; + $trec = new TransportRecord($tr); + $trec->trtok = $trtok = $tr->_createTransportToken(); + $trec->row = array_merge($defaults, + array('trtype'=>$trtype, 'direction'=>$direction)); + $trec->recalled = TRUE; + if (!isset($defaults['title'])) { + $defaults['title'] = $trec->getTitle(); + if (PEAR::isError($defaults['title'])) { + return $defaults['title']; + } + } + $id = $CC_DBC->nextId($CC_CONFIG['transSequence']); + $names = "id, trtok, direction, state, trtype, start, ts"; + $values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()"; + foreach ($defaults as $k => $v) { + $sqlVal = $trec->_getSqlVal($k, $v); + $names .= ", $k"; + $values .= ", $sqlVal"; + } + $query = " + INSERT INTO ".$CC_CONFIG['transTable']." + ($names) + VALUES + ($values) + "; + $res = $CC_DBC->query($query); + if (PEAR::isError($res)) { + return $res; + } + return $trec; + } + + + /** + * Recall transport record from DB + * + * @param Transport $tr + * @param string $trtok + * transport token + * @return TransportRecord + */ + function recall(&$tr, $trtok) + { + global $CC_DBC, $CC_CONFIG; + $trec = new TransportRecord($tr); + $trec->trtok = $trtok; + $row = $CC_DBC->getRow(" + SELECT + id, trtok, state, trtype, direction, + to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken, + fname, localfile, url, rtrtok, mdtrtok, uid, + expectedsize, realsize, expectedsum, realsum, + errmsg, title, jobpid + FROM ".$CC_CONFIG['transTable']." + WHERE trtok='$trtok' + "); + if (PEAR::isError($row)) { + return $row; + } + if (is_null($row)) { + return PEAR::raiseError("TransportRecord::recall:". + " invalid transport token ($trtok)", TRERR_TOK + ); + } + $row['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']); + $row['gunid'] = StoredFile::NormalizeGunid($row['gunid']); + $trec->row = $row; + $trec->recalled = TRUE; + return $trec; + } + + + /** + * Set state of transport record + * + * @param string $newState + * @param array $data + * other data fields to set + * @param string $oldState + * check old state and do nothing if differ + * @param boolean $lock + * check lock and do nothing if differ + * @return boolean success + */ + function setState($newState, $data=array(), $oldState=NULL, $lock=NULL) + { + global $CC_CONFIG, $CC_DBC; + $set = " state='$newState', ts=now()"; + if (!is_null($lock)) { + $slock = ($lock ? 'Y' : 'N'); + $nlock = (!$lock); + $snlock = ($nlock ? 'Y' : 'N'); + $set .= ", lock='$snlock'"; + } + foreach ($data as $k => $v) { + $set .= ", $k=".$this->_getSqlVal($k, $v); + } + $r = $CC_DBC->query(" + UPDATE ".$CC_CONFIG['transTable']." + SET $set + WHERE trtok='{$this->trtok}'". + (is_null($oldState) ? '' : " AND state='$oldState'"). + (is_null($lock) ? '' : " AND lock = '$slock'") + ); + if (PEAR::isError($r)) { + return $r; + } + // return TRUE; + $affRows = $CC_DBC->affectedRows(); + if (PEAR::isError($affRows)) { + return $affRows; + } + return ($affRows == 1); + } + + + /** + * Return state of transport record + * + * @return string + * state + */ + function getState() + { + if (!$this->recalled) { + return PEAR::raiseError("TransportRecord::getState:". + " not recalled ({$this->trtok})", TRERR_TOK + ); + } + return $this->row['state']; + } + + + /** + * Set lock on transport record and save/clear process id + * + * @param boolean $lock + * lock if true, release lock if false + * @param int $pid + * process id + * @return mixed + * true or error + */ + function setLock($lock, $pid=NULL) + { + global $CC_CONFIG, $CC_DBC; + $pidsql = (is_null($pid) ? "NULL" : "$pid" ); + if ($this->dropped) { + return TRUE; + } + $slock = ($lock ? 'Y' : 'N'); + $nlock = (!$lock); + $snlock = ($nlock ? 'Y' : 'N'); + $r = $CC_DBC->query(" + UPDATE ".$CC_CONFIG['transTable']." + SET lock='$slock', jobpid=$pidsql, ts=now() + WHERE trtok='{$this->trtok}' AND lock = '$snlock'" + ); + if (PEAR::isError($r)) { + return $r; + } + $affRows = $CC_DBC->affectedRows(); + if (PEAR::isError($affRows)) { + return $affRows; + } + if ($affRows === 0) { + $ltxt = ($lock ? 'lock' : 'unlock' ); + return PEAR::raiseError( + "TransportRecord::setLock: can't $ltxt ({$this->trtok})" + ); + } + return TRUE; + } + + + /** + * Return type of transport + * + * @return string + * Transport type + */ + function getTransportType() + { + if (!$this->recalled) { + return PEAR::raiseError("TransportRecord::getTransportType:". + " not recalled ({$this->trtok})", TRERR_TOK + ); + } + return $this->row['trtype']; + } + + + /** + * Kill transport job (on pause or cancel) + * + * @return string + * Transport type + */ + function killJob() + { + if (!$this->recalled) { + return PEAR::raiseError("TransportRecord::getTransportType:". + " not recalled ({$this->trtok})", TRERR_TOK + ); + } + $jobpid = $this->row['jobpid']; + $res = system("pkill -P $jobpid", $status); + } + + + /** + * Set state to failed and set error message in transport record + * + * @param string $txt + * base part of error message + * @param PEAR_Error $eo + * (opt.) error msg can be construct from it + * @return mixed + * boolean true or error + */ + function fail($txt='', $eo=NULL) + { + if (!$this->recalled) { + return PEAR::raiseError("TransportRecord::fail:". + " not recalled ({$this->trtok})", TRERR_TOK + ); + } + $msg = $txt; + if (!is_null($eo)) { + $msg .= $eo->getMessage()." ".$eo->getUserInfo(). + " [".$eo->getCode()."]"; + } + $r = $this->setState('failed', array('errmsg'=>$msg)); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /** + * Close transport record + * + * @return mixed + * boolean true or error + */ + function close() + { + global $CC_CONFIG, $CC_DBC; + if (!$this->recalled) { + return PEAR::raiseError("TransportRecord::close:". + " not recalled ({$this->trtok})", TRERR_TOK + ); + } + if (TR_LEAVE_CLOSED) { + $r = $this->setState('closed'); + if (PEAR::isError($r)) { + return $r; + } + } else { + $r = $CC_DBC->query(" + DELETE FROM ".$CC_CONFIG['transTable']." + WHERE trtok='{$this->trtok}' + "); + if (PEAR::isError($r)) { + return $r; + } + $this->recalled = FALSE; + $this->dropped = TRUE; + } + return TRUE; + } + + + /** + * Add field specific envelopes to values (e.g. ' around strings) + * + * @param string $fldName + * field name + * @param mixed $fldVal + * field value + * @return string + */ + function _getSqlVal($fldName, $fldVal) + { + switch ($fldName) { + case 'realsize': + case 'expectedsize': + case 'uid': + return ("$fldVal"!='' ? "$fldVal" : "NULL"); + break; + case 'gunid': + case 'pdtoken': + return "x'$fldVal'::bigint"; + break; + default: + $fldVal = pg_escape_string($fldVal); + return "'$fldVal'"; + break; + } + } + + + /** + * Get title from transported object's metadata (if exists) + * + * @return string + * the title or descriptive string + */ + function getTitle() + { + $defStr = 'unknown'; + $trtype = $this->getTransportType(); //contains recall check + if (PEAR::isError($trtype)) { + return $trtype; + } + switch ($trtype) { + case "audioclip": + case "playlist": + case "playlistPkg": + case "metadata": + $title = $this->gb->bsGetTitle(NULL, $this->row['gunid']); + if (is_null($title)) { + $title = $defStr; + } + if (PEAR::isError($title)) { + if ($title->getCode() == GBERR_FOBJNEX) { + $title = $defStr; + } else { + return $title; + } + } + break; + case "searchjob": + $title = 'searchjob'; + break; + case "file": + $title = ( isset($this->row['localfile']) ? + basename($this->row['localfile']) : 'regular file'); + break; + default: + $title = $defStr; + } + return $title; + } + +} // class TransportRecord +?> \ No newline at end of file diff --git a/application/models/Users.php b/application/models/Users.php new file mode 100644 index 000000000..f7c51c2f2 --- /dev/null +++ b/application/models/Users.php @@ -0,0 +1,36 @@ +GetAll($sql); + } + + public function getHosts() { + return $this->getUsers(array('H', 'A')); + } + +} diff --git a/application/models/Validator.php b/application/models/Validator.php new file mode 100644 index 000000000..a53b9fdf4 --- /dev/null +++ b/application/models/Validator.php @@ -0,0 +1,385 @@ + + *- audioclip
+ *- playlist
+ *- metadata
+ *- file
+ *audioClipFormat.php + *webstreamFormat.php + *playlistFormat.php + * + * It probably should be replaced by XML schema validation in the future. + * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + */ +class Validator { + /** + * Format type of validated document + * @var string + */ + private $format = NULL; + + /** + * Preloaded format tree structure + * @var array + */ + private $formTree = NULL; + + /** + * Gunid of validated file for identification in mass input + * @var string + */ + private $gunid = NULL; + + + /** + * Constructor + * + * @param string $format + * format type of validated document + * @param string $gunid + * gunid of validated file for identification in mass input + */ + public function __construct($format, $gunid) + { + $format = strtolower($format); + $this->format = $format; + $this->gunid = $gunid; + $formats = array( + 'audioclip' => "audioClipFormat", + 'playlist' => "playlistFormat", + 'webstream' => "webstreamFormat", + ); + if (!isset($formats[$format])) { + return $this->_err(VAL_FORMAT); + } + $formatName = $formats[$format]; + $formatFile = dirname(__FILE__)."/$formatName.php"; + if (!file_exists($formatFile)) { + return $this->_err(VAL_FORMAT); + } + require($formatFile); + $this->formTree = $$formatName; + } + + + /** + * Validate document - only wrapper for validateNode method + * + * @param object $data + * validated object tree + * @return mixed + * TRUE or PEAR::error + */ + function validate(&$data) + { + $r = $this->validateNode($data, $this->formTree['_root']); + return $r; + } + + + /** + * Validate one metadata value (on insert/update) + * + * @param string $fname + * parent element name + * @param string $category + * qualif.category name + * @param string $predxml + * 'A' | 'T' (attr or tag) + * @param string $value + * validated element value + * @return TRUE|PEAR_Error + */ + function validateOneValue($fname, $category, $predxml, $value) + { + $formTree =& $this->formTree; + switch ($predxml) { + case 'T': + if (!$this->isChildInFormat($fname, $category)) { + return $this->_err(VAL_UNKNOWNE, "$category in $fname"); + } + break; + case 'A': + if (!$this->isAttrInFormat($fname, $category)) { + return $this->_err(VAL_UNKNOWNA, "$category in $fname"); + } + break; + case 'N': + return TRUE; + break; + default: + return $this->_err(VAL_PREDXML, $predxml); + } + if (isset($formTree[$category]['regexp'])) { + // echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n"; + if (!preg_match("|{$formTree[$category]['regexp']}|", $value)) { + return $this->_err(VAL_CONTENT, "$category/$value"); + } + } + } + + + /** + * Validation of one element node from object tree + * + * @param object $node + * validated node + * @param string $fname + * actual name in format structure + * @return mixed + * TRUE or PEAR::error + */ + function validateNode(&$node, $fname) + { + $dname = (($node->ns? $node->ns.":" : '').$node->name); + $formTree =& $this->formTree; + if (DEBUG) { + echo"\nVAL::validateNode: 1 $dname/$fname\n"; + } + // check root node name: + if ($dname != $fname) { + return $this->_err(VAL_ROOT, $fname); + } + // check if this element is defined in format: + if (!isset($formTree[$fname])) { + return $this->_err(VAL_NOTDEF, $fname); + } + // check element content + if (isset($formTree[$fname]['regexp'])) { + // echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n"; + if (!preg_match("|{$formTree[$fname]['regexp']}|", $node->content)) { + return $this->_err(VAL_CONTENT, "$fname/{$node->content}"); + } + } + // validate attributes: + $ra = $this->validateAttributes($node, $fname); + if (PEAR::isError($ra)) { + return $ra; + } + // validate children: + $r = $this->validateChildren($node, $fname); + if (PEAR::isError($r)) { + return $r; + } + return TRUE; + } + + + /** + * Validation of attributes + * + * @param object $node + * validated node + * @param string $fname + * actual name in format structure + * @return mixed + * TRUE or PEAR::error + */ + function validateAttributes(&$node, $fname) + { + $formTree =& $this->formTree; + $attrs = array(); + // check if all attrs are permitted here: + foreach ($node->attrs as $i => $attr) { + $aname = (($attr->ns? $attr->ns.":" : '').$attr->name); + $attrs[$aname] =& $node->attrs[$i]; + if (!$this->isAttrInFormat($fname, $aname)) { + return $this->_err(VAL_UNKNOWNA, $aname); + } + // check attribute format + // echo "XXA $aname\n"; + if (isset($formTree[$aname]['regexp'])) { + // echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n"; + if (!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val)) { + return $this->_err(VAL_ATTRIB, "$aname [".var_export($attr->val,TRUE)."]"); + } + } + } + // check if all required attrs are here: + if (isset($formTree[$fname]['attrs'])) { + $fattrs =& $formTree[$fname]['attrs']; + if (isset($fattrs['required'])) { + foreach ($fattrs['required'] as $i => $attr) { + if (!isset($attrs[$attr])) { + return $this->_err(VAL_NOREQA, $attr); + } + } + } + } + return TRUE; + } + + + /** + * Validation children nodes + * + * @param object $node + * validated node + * @param string $fname + * actual name in format structure + * @return mixed + * TRUE or PEAR::error + */ + function validateChildren(&$node, $fname) + { + $formTree =& $this->formTree; + $childs = array(); + // check if all children are permitted here: + foreach ($node->children as $i => $ch) { + $chname = (($ch->ns? $ch->ns.":" : '').$ch->name); + // echo "XXE $chname\n"; + if (!$this->isChildInFormat($fname, $chname)) { + return $this->_err(VAL_UNKNOWNE, $chname); + } + // call children recursive: + $r = $this->validateNode($node->children[$i], $chname); + if (PEAR::isError($r)) { + return $r; + } + $childs[$chname] = TRUE; + } + // check if all required children are here: + if (isset($formTree[$fname]['childs'])) { + $fchilds =& $formTree[$fname]['childs']; + if (isset($fchilds['required'])) { + foreach ($fchilds['required'] as $i => $ch) { + if (!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch); + } + } + // required one from set + if (isset($fchilds['oneof'])) { + $one = FALSE; + foreach ($fchilds['oneof'] as $i => $ch) { + if (isset($childs[$ch])) { + if ($one) { + return $this->_err(VAL_UNEXPONEOF, "$ch in $fname"); + } + $one = TRUE; + } + } + if (!$one) { + return $this->_err(VAL_NOONEOF); + } + } + } + return TRUE; + } + + + /** + * Test if child is presented in format structure + * + * @param string $fname + * node name in format structure + * @param string $chname + * child node name + * @return boolean + */ + function isChildInFormat($fname, $chname) + { + $listo = $this->isInFormatAs($fname, $chname, 'childs', 'optional'); + $listr = $this->isInFormatAs($fname, $chname, 'childs', 'required'); + $list1 = $this->isInFormatAs($fname, $chname, 'childs', 'oneof'); + return ($listo!==FALSE || $listr!==FALSE || $list1!==FALSE); + } + + + /** + * Test if attribute is presented in format structure + * + * @param string $fname + * node name in format structure + * @param string $aname + * attribute name + * @return boolean + */ + function isAttrInFormat($fname, $aname) + { + $listr = $this->isInFormatAs($fname, $aname, 'attrs', 'required'); + $listi = $this->isInFormatAs($fname, $aname, 'attrs', 'implied'); + $listn = $this->isInFormatAs($fname, $aname, 'attrs', 'normal'); + return ($listr!==FALSE || $listi!==FALSE || $listn!==FALSE); + } + + + /** + * Check if node/attribute is presented in format structure + * + * @param string $fname + * node name in format structure + * @param string $chname + * node/attribute name + * @param string $nType + * 'childs' | 'attrs' + * @param string $reqType + *+ *
+ * @return mixed + * boolean/int (index int format array returned if found) + */ + function isInFormatAs($fname, $chname, $nType='childs', $reqType='required') + { + $formTree =& $this->formTree; + $listed = ( + isset($formTree[$fname][$nType][$reqType]) ? + array_search($chname, $formTree[$fname][$nType][$reqType]) : + FALSE + ); + return $listed; + } + + + /** + * Error exception generator + * + * @param int $errno + * erron code + * @param string $par + * optional string for more descriptive error messages + * @return PEAR_Error + */ + function _err($errno, $par='') + { + $msg = array( + VAL_ROOT => 'Wrong root element', + VAL_NOREQE => 'Required element missing', + VAL_NOONEOF => 'One-of element missing', + VAL_UNKNOWNE => 'Unknown element', + VAL_UNKNOWNA => 'Unknown attribute', + VAL_NOTDEF => 'Not defined', + VAL_UNEXPONEOF => 'Unexpected second object from one-of set', + VAL_FORMAT => 'Unknown format', + VAL_CONTENT => 'Invalid content', + VAL_NOREQA => 'Required attribute missing', + VAL_ATTRIB => 'Invalid attribute format', + VAL_PREDXML => 'Invalid predicate type', + ); + return PEAR::raiseError( + "Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})", + $errno + ); + } + + +} // class Validator + +?> \ No newline at end of file diff --git a/application/models/XmlParser.php b/application/models/XmlParser.php new file mode 100644 index 000000000..89d59e123 --- /dev/null +++ b/application/models/XmlParser.php @@ -0,0 +1,398 @@ +ns = $a['namespace']; + $this->name = $a['localPart']; + $this->attrs = $attrs; + $this->nSpaces = $nSpaces; + $this->children = $children; + } +} // class XmlElement + + +/* ================================================================ Attribute */ +/** + * Object representation of one XML attribute + * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + * @see MetaData + */ +class XmlAttrib { + /** + * Namespace prefix + * @var string + */ + public $ns; + + /** + * Attribute name + * @var string + */ + public $name; + + /** + * Attribute value + * @var string + */ + public $val; + + /** + * @param string $atns + * namespace prefix + * @param string $atnm + * attribute name + * @param string $atv + * attribute value + */ + public function __construct($atns, $atnm, $atv) + { + $this->ns = $atns; + $this->name = $atnm; + $this->val = $atv; + } +} // fn XmlAttrib + + +/* =================================================================== Parser */ +/** + * XML parser object encapsulation + * + * @package Campcaster + * @subpackage StorageServer + * @copyright 2010 Sourcefabric O.P.S. + * @license http://www.gnu.org/licenses/gpl.txt + * @see MetaData + */ +class XmlParser { + /** + * Tree of nodes + * @var array + */ + private $tree = NULL; + + /** + * Parse stack + * @var array + */ + private $stack = array(); + + /** + * Error structure + * @var array + */ + private $err = array(FALSE, ''); + + /** + * @param string $data + * XML string to be parsed + */ + public function __construct($data){ + $xml_parser = xml_parser_create('UTF-8'); + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE); + xml_set_object($xml_parser, $this); + xml_set_element_handler($xml_parser, "startTag", "endTag"); + xml_set_character_data_handler($xml_parser, 'characterData'); + $res = xml_parse($xml_parser, $data, TRUE); + if (!$res) { + $this->err = array(TRUE, + sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser) + ) + ); +// var_dump($data); + } + xml_parser_free($xml_parser); + } + + + /** + * Parse XML file or string + * + * @param string $data + * local path to XML file or XML string + * @param string $loc + * location: 'file'|'string' + * @return array + * reference, parse result tree (or PEAR::error) + */ + function &parse($data='', $loc='file') + { + switch ($loc) { + case "file": + if (!is_file($data)) { + return PEAR::raiseError( + "XmlParser::parse: file not found ($data)" + ); + } + if (!is_readable($data)) { + return PEAR::raiseError( + "XmlParser::parse: can't read file ($data)" + ); + } + $data = file_get_contents($data); + case "string": + $parser = new XmlParser($data); + if ($parser->isError()) { + return PEAR::raiseError( + "XmlParser::parse: ".$parser->getError() + ); + } + $tree = $parser->getTree(); + break; + default: + return PEAR::raiseError( + "XmlParser::parse: unsupported source location ($loc)" + ); + } + return $tree; + } + + + /** + * Start tag handler + * + * @param resource $parser + * reference to parser resource + * @param string $fullname + * element name + * @param array $attrs + * array of attributes + * @return none + */ + function startTag($parser, $fullname, $attrs) { + $nSpaces = array(); + foreach ($attrs as $atn => $atv) { + $a = XML_Util::splitQualifiedName($atn); + $atns = $a['namespace']; + $atnm = $a['localPart']; + unset($attrs[$atn]); + if ($atns == 'xmlns') { + $nSpaces[$atnm] = $atv; + } else if ($atns == NULL && $atnm == 'xmlns') { + $nSpaces[''] = $atv; + } else { + $attrs[$atn] = new XmlAttrib($atns, $atnm, $atv); + } + } + $el = new XmlElement($fullname, $attrs, $nSpaces); + array_push($this->stack, $el); + } + + + /** + * End tag handler + * + * @param resource $parser + * reference to parser resource + * @param string $fullname + * element name + * @return none + */ + function endTag($parser, $fullname) { + $cnt = count($this->stack); + if ($cnt > 1) { + $this->stack[$cnt-2]->children[] = $this->stack[$cnt-1]; + $lastEl = array_pop($this->stack); + } else { + $this->tree = $this->stack[0]; + } + } + + + /** + * Character data handler + * + * @param resource $parser + * reference to parser resource + * @param string $data + * @return none + */ + function characterData($parser, $data) { + $cnt = count($this->stack); + if (trim($data)!='') { + $this->stack[$cnt-1]->content .= $data; + } + } + + + /** + * Default handler + * + * @param resource $parser + * reference to parser resource + * @param string $data + * @return none + */ + function defaultHandler($parser, $data) + { + $cnt = count($this->stack); + //if(substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";"){ + // $this->stack[$cnt-1]->content .= trim($data); + //}else{ + $this->stack[$cnt-1]->content .= "*** $data ***"; + //} + } + + + /** + * Return result tree + * + * @return array + * tree structure + */ + function getTree() + { + return $this->tree; + } + + + /** + * Return error string + * + * @return boolean + * whether error occured + */ + function isError() + { + return $this->err[0]; + } + + + /** + * Return error string + * + * @return string + * error message + */ + function getError() + { + return $this->err[1]; + } + + + /* ----------------------------------- auxiliary methos for serialization */ + /** + * Serialize metadata of one file + * + * @return string, serialized XML + */ + function serialize() + { + $res = ''; + $res .= $this->serializeEl($this->tree); + $res .= "\n"; + return $res; + } + + + /** + * Serialize one metadata element + * + * @param el object, element object + * @param lvl int, level for indentation + * @return string, serialized XML + */ + function serializeEl($el, $lvl=0) + { + $ind = str_repeat(" ", $lvl); + $elNs = $el->ns; + $elName = $el->name; + $attrs = XML_Util::attributesToString($el->attrs); + $fullName = ($elNs=='' ? '' : "$elNs:")."$elName"; + $res = "\n{$ind}<{$fullName}{$attrs}>"; + $haveCh = (count($el->children)>0); + foreach ($el->children as $ch) { + $res .= $this->serializeEl($ch, $lvl+1); + } + $res .= XML_Util::replaceEntities("{$el->content}"); + if ($haveCh) { + $res .= "\n{$ind}"; + } + $res .= "{$fullName}>"; + return $res; + } + + + /* -------------------------------------------------------- debug methods */ + /** + * Debug dump of tree + * + * @return hash, tree structure + */ + function dump() + { + var_dump($this->tree); + } + +} +?> \ No newline at end of file diff --git a/application/models/audioClipFormat.php b/application/models/audioClipFormat.php new file mode 100644 index 000000000..f7fd506b7 --- /dev/null +++ b/application/models/audioClipFormat.php @@ -0,0 +1,328 @@ +'audioClip', + 'audioClip'=>array( + 'childs'=>array( + 'required'=>array('metadata'), + ), + ), + 'metadata'=>array( + 'childs'=>array( + 'required'=>array( + 'dc:title', 'dcterms:extent' + ), + 'optional'=>array( + 'dc:identifier', + 'dc:creator', 'dc:source', 'ls:genre', + 'ls:year', 'dc:type', 'dc:description', 'dc:format', + 'ls:bpm', 'ls:rating', 'ls:encoded_by', 'ls:track_num', + 'ls:disc_num', 'ls:disc_num', 'dc:publisher', 'ls:composer', + 'ls:bitrate', 'ls:channels', 'ls:samplerate', 'ls:encoder', + 'ls:crc', 'ls:lyrics', 'ls:orchestra', 'ls:conductor', + 'ls:lyricist', 'ls:originallyricist', 'ls:radiostationname', + 'ls:audiofileinfourl', 'ls:artisturl', 'ls:audiosourceurl', + 'ls:radiostationurl', 'ls:buycdurl', 'ls:isrcnumber', + 'ls:catalognumber', 'ls:originalartist', 'dc:rights', + 'ls:license', 'dc:title', 'dcterms:temporal', + 'dcterms:spatial', 'dcterms:entity', 'dc:description', + 'dc:creator', 'dc:subject', 'dc:type', 'dc:format', + 'dc:contributor', 'dc:language', 'dc:rights', + 'dcterms:isPartOf', 'dc:date', + 'dc:publisher', + // extra + 'dcterms:alternative', 'ls:filename', 'ls:mtime', + // added lately by sebastian + 'ls:mood', + ), + ), + 'namespaces'=>array( + 'dc'=>"http://purl.org/dc/elements/1.1/", + 'dcterms'=>"http://purl.org/dc/terms/", + 'xbmf'=>"http://www.streamonthefly.org/xbmf", + 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance", + 'xml'=>"http://www.w3.org/XML/1998/namespace", + ), + ), + 'dc:identifier'=>array( + 'type'=>'Text', + 'auto'=>TRUE, + ), + 'dc:title'=>array( + 'type'=>'Text', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:alternative'=>array( + 'type'=>'Text', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:extent'=>array( + 'type'=>'Time', +// 'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$', + 'regexp'=>'^((\d{1,2}:)?\d{1,2}:)?\d{1,20}(.\d{1,6})?$', + ), + 'dc:creator'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:source'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:genre'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:year'=>array( + 'type'=>'Menu', + 'area'=>'Music', + ), + 'dc:type'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:description'=>array( + 'type'=>'Longtext', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:format'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:bpm'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:rating'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:encoded_by'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:track_num'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:disc_num'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:disc_num'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:publisher'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:composer'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:bitrate'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:channels'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:samplerate'=>array( + 'type'=>'Menu', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:encoder'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:crc'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:lyrics'=>array( + 'type'=>'Longtext', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:orchestra'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:conductor'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:lyricist'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:originallyricist'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:radiostationname'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:audiofileinfourl'=>array( + 'type'=>'URL', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:artisturl'=>array( + 'type'=>'URL', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:audiosourceurl'=>array( + 'type'=>'URL', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:radiostationurl'=>array( + 'type'=>'URL', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:buycdurl'=>array( + 'type'=>'URL', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:isrcnumber'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:catalognumber'=>array( + 'type'=>'Number', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:originalartist'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:rights'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:license'=>array( + 'type'=>'Text', + 'area'=>'Music', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:title'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:temporal'=>array( + 'type'=>'Time/Date', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:spatial'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:entity'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:description'=>array( + 'type'=>'Longtext', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:creator'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:subject'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:type'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:format'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:contributor'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:language'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:rights'=>array( + 'type'=>'Menu', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dcterms:isPartOf'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:date'=>array( + 'type'=>'Date', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'dc:publisher'=>array( + 'type'=>'Text', + 'area'=>'Talk', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + + 'ls:filename'=>array( + 'type'=>'Text', + 'attrs'=>array('implied'=>array('xml:lang')), + ), + 'ls:mtime'=>array( + 'type'=>'Int', +// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$', + ), +); + +?> \ No newline at end of file diff --git a/application/models/campcaster/CcAccess.php b/application/models/campcaster/CcAccess.php new file mode 100644 index 000000000..e3171bdfa --- /dev/null +++ b/application/models/campcaster/CcAccess.php @@ -0,0 +1,18 @@ +length; + } + + public function setDbLength($time) + { + $this->length = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH; + return Common::setTimeInSub($this, 'LENGTH', $time); + } + + +} // CcFiles diff --git a/application/models/campcaster/CcFilesPeer.php b/application/models/campcaster/CcFilesPeer.php new file mode 100644 index 000000000..047a8d8bb --- /dev/null +++ b/application/models/campcaster/CcFilesPeer.php @@ -0,0 +1,18 @@ +prepare($sql); + $stmt->bindValue(':p1', $this->getDbId()); + $stmt->execute(); + return $stmt->fetchColumn(); + } + + public function computeLength() + { + $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); + + $sql = 'SELECT SUM('.CcPlaylistcontentsPeer::CLIPLENGTH.') AS length' + . ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME + . ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1'; + + $stmt = $con->prepare($sql); + $stmt->bindValue(':p1', $this->getDbId()); + $stmt->execute(); + return $stmt->fetchColumn(); + } + + +} // CcPlaylist diff --git a/application/models/campcaster/CcPlaylistPeer.php b/application/models/campcaster/CcPlaylistPeer.php new file mode 100644 index 000000000..097895b10 --- /dev/null +++ b/application/models/campcaster/CcPlaylistPeer.php @@ -0,0 +1,18 @@ +fadein; + } + + public function setDbFadein($time) + { + $this->fadein = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN; + Common::setTimeInSub($this, 'FADEIN', $time); + } + + public function getDbFadeout() + { + return $this->fadeout; + } + + public function setDbFadeout($time) + { + $this->fadeout = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT; + Common::setTimeInSub($this, 'FADEOUT', $time); + } + + public function getDbCuein() + { + return $this->cuein; + } + + public function setDbCuein($time) + { + $this->cuein = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN; + Common::setTimeInSub($this, 'CUEIN', $time); + } + + public function getDbCueout() + { + return $this->cueout; + } + + public function setDbCueout($time) + { + $this->cueout = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT; + Common::setTimeInSub($this, 'CUEOUT', $time); + } + + public function getDbCliplength() + { + return $this->cliplength; + } + + public function setDbCliplength($time) + { + $this->cliplength = $time; + //$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH; + Common::setTimeInSub($this, 'CLIPLENGTH', $time); + } + + + + +} // CcPlaylistcontents diff --git a/application/models/campcaster/CcPlaylistcontentsPeer.php b/application/models/campcaster/CcPlaylistcontentsPeer.php new file mode 100644 index 000000000..5fe6cf288 --- /dev/null +++ b/application/models/campcaster/CcPlaylistcontentsPeer.php @@ -0,0 +1,18 @@ +prepare($sql); + $stmt->bindValue(':f1', $time); + $stmt->bindValue(':p1', $row->getDbId()); + $stmt->execute(); + } +} diff --git a/application/models/campcaster/map/CcAccessTableMap.php b/application/models/campcaster/map/CcAccessTableMap.php new file mode 100644 index 000000000..5da2dae21 --- /dev/null +++ b/application/models/campcaster/map/CcAccessTableMap.php @@ -0,0 +1,61 @@ +setName('cc_access'); + $this->setPhpName('CcAccess'); + $this->setClassname('CcAccess'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_access_id_seq'); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('GUNID', 'Gunid', 'CHAR', false, 32, null); + $this->addColumn('TOKEN', 'Token', 'BIGINT', false, null, null); + $this->addColumn('CHSUM', 'Chsum', 'CHAR', true, 32, ''); + $this->addColumn('EXT', 'Ext', 'VARCHAR', true, 128, ''); + $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 20, ''); + $this->addColumn('PARENT', 'Parent', 'BIGINT', false, null, null); + $this->addForeignKey('OWNER', 'Owner', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('owner' => 'id', ), null, null); + } // buildRelations() + +} // CcAccessTableMap diff --git a/application/models/campcaster/map/CcBackupTableMap.php b/application/models/campcaster/map/CcBackupTableMap.php new file mode 100644 index 000000000..a2c3f3af7 --- /dev/null +++ b/application/models/campcaster/map/CcBackupTableMap.php @@ -0,0 +1,55 @@ +setName('cc_backup'); + $this->setPhpName('CcBackup'); + $this->setClassname('CcBackup'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('TOKEN', 'Token', 'VARCHAR', true, 64, null); + $this->addColumn('SESSIONID', 'Sessionid', 'VARCHAR', true, 64, null); + $this->addColumn('STATUS', 'Status', 'VARCHAR', true, 32, null); + $this->addColumn('FROMTIME', 'Fromtime', 'TIMESTAMP', true, null, null); + $this->addColumn('TOTIME', 'Totime', 'TIMESTAMP', true, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcBackupTableMap diff --git a/application/models/campcaster/map/CcFilesTableMap.php b/application/models/campcaster/map/CcFilesTableMap.php new file mode 100644 index 000000000..5c8fe05f1 --- /dev/null +++ b/application/models/campcaster/map/CcFilesTableMap.php @@ -0,0 +1,107 @@ +setName('cc_files'); + $this->setPhpName('CcFiles'); + $this->setClassname('CcFiles'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_files_id_seq'); + // columns + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('GUNID', 'Gunid', 'CHAR', true, 32, null); + $this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, ''); + $this->addColumn('MIME', 'Mime', 'VARCHAR', true, 255, ''); + $this->addColumn('FTYPE', 'Ftype', 'VARCHAR', true, 128, ''); + $this->addColumn('FILEPATH', 'filepath', 'LONGVARCHAR', false, null, ''); + $this->addColumn('STATE', 'State', 'VARCHAR', true, 128, 'empty'); + $this->addColumn('CURRENTLYACCESSING', 'Currentlyaccessing', 'INTEGER', true, null, 0); + $this->addForeignKey('EDITEDBY', 'Editedby', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('MTIME', 'Mtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('MD5', 'Md5', 'CHAR', false, 32, null); + $this->addColumn('TRACK_TITLE', 'TrackTitle', 'VARCHAR', false, 512, null); + $this->addColumn('ARTIST_NAME', 'ArtistName', 'VARCHAR', false, 512, null); + $this->addColumn('BIT_RATE', 'BitRate', 'VARCHAR', false, 32, null); + $this->addColumn('SAMPLE_RATE', 'SampleRate', 'VARCHAR', false, 32, null); + $this->addColumn('FORMAT', 'Format', 'VARCHAR', false, 128, null); + $this->addColumn('LENGTH', 'DbLength', 'TIME', false, null, null); + $this->addColumn('ALBUM_TITLE', 'AlbumTitle', 'VARCHAR', false, 512, null); + $this->addColumn('GENRE', 'Genre', 'VARCHAR', false, 64, null); + $this->addColumn('COMMENTS', 'Comments', 'LONGVARCHAR', false, null, null); + $this->addColumn('YEAR', 'Year', 'VARCHAR', false, 16, null); + $this->addColumn('TRACK_NUMBER', 'TrackNumber', 'INTEGER', false, null, null); + $this->addColumn('CHANNELS', 'Channels', 'INTEGER', false, null, null); + $this->addColumn('URL', 'Url', 'VARCHAR', false, 1024, null); + $this->addColumn('BPM', 'Bpm', 'VARCHAR', false, 8, null); + $this->addColumn('RATING', 'Rating', 'VARCHAR', false, 8, null); + $this->addColumn('ENCODED_BY', 'EncodedBy', 'VARCHAR', false, 255, null); + $this->addColumn('DISC_NUMBER', 'DiscNumber', 'VARCHAR', false, 8, null); + $this->addColumn('MOOD', 'Mood', 'VARCHAR', false, 64, null); + $this->addColumn('LABEL', 'Label', 'VARCHAR', false, 512, null); + $this->addColumn('COMPOSER', 'Composer', 'VARCHAR', false, 512, null); + $this->addColumn('ENCODER', 'Encoder', 'VARCHAR', false, 64, null); + $this->addColumn('CHECKSUM', 'Checksum', 'VARCHAR', false, 256, null); + $this->addColumn('LYRICS', 'Lyrics', 'LONGVARCHAR', false, null, null); + $this->addColumn('ORCHESTRA', 'Orchestra', 'VARCHAR', false, 512, null); + $this->addColumn('CONDUCTOR', 'Conductor', 'VARCHAR', false, 512, null); + $this->addColumn('LYRICIST', 'Lyricist', 'VARCHAR', false, 512, null); + $this->addColumn('ORIGINAL_LYRICIST', 'OriginalLyricist', 'VARCHAR', false, 512, null); + $this->addColumn('RADIO_STATION_NAME', 'RadioStationName', 'VARCHAR', false, 512, null); + $this->addColumn('INFO_URL', 'InfoUrl', 'VARCHAR', false, 512, null); + $this->addColumn('ARTIST_URL', 'ArtistUrl', 'VARCHAR', false, 512, null); + $this->addColumn('AUDIO_SOURCE_URL', 'AudioSourceUrl', 'VARCHAR', false, 512, null); + $this->addColumn('RADIO_STATION_URL', 'RadioStationUrl', 'VARCHAR', false, 512, null); + $this->addColumn('BUY_THIS_URL', 'BuyThisUrl', 'VARCHAR', false, 512, null); + $this->addColumn('ISRC_NUMBER', 'IsrcNumber', 'VARCHAR', false, 512, null); + $this->addColumn('CATALOG_NUMBER', 'CatalogNumber', 'VARCHAR', false, 512, null); + $this->addColumn('ORIGINAL_ARTIST', 'OriginalArtist', 'VARCHAR', false, 512, null); + $this->addColumn('COPYRIGHT', 'Copyright', 'VARCHAR', false, 512, null); + $this->addColumn('REPORT_DATETIME', 'ReportDatetime', 'VARCHAR', false, 32, null); + $this->addColumn('REPORT_LOCATION', 'ReportLocation', 'VARCHAR', false, 512, null); + $this->addColumn('REPORT_ORGANIZATION', 'ReportOrganization', 'VARCHAR', false, 512, null); + $this->addColumn('SUBJECT', 'Subject', 'VARCHAR', false, 512, null); + $this->addColumn('CONTRIBUTOR', 'Contributor', 'VARCHAR', false, 512, null); + $this->addColumn('LANGUAGE', 'Language', 'VARCHAR', false, 512, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); + $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); + } // buildRelations() + +} // CcFilesTableMap diff --git a/application/models/campcaster/map/CcPermsTableMap.php b/application/models/campcaster/map/CcPermsTableMap.php new file mode 100644 index 000000000..7a869b2c3 --- /dev/null +++ b/application/models/campcaster/map/CcPermsTableMap.php @@ -0,0 +1,56 @@ +setName('cc_perms'); + $this->setPhpName('CcPerms'); + $this->setClassname('CcPerms'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('PERMID', 'Permid', 'INTEGER', true, null, null); + $this->addForeignKey('SUBJ', 'Subj', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('ACTION', 'Action', 'VARCHAR', false, 20, null); + $this->addColumn('OBJ', 'Obj', 'INTEGER', false, null, null); + $this->addColumn('TYPE', 'Type', 'CHAR', false, 1, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('subj' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // CcPermsTableMap diff --git a/application/models/campcaster/map/CcPlaylistTableMap.php b/application/models/campcaster/map/CcPlaylistTableMap.php new file mode 100644 index 000000000..cfb6f23de --- /dev/null +++ b/application/models/campcaster/map/CcPlaylistTableMap.php @@ -0,0 +1,61 @@ +setName('cc_playlist'); + $this->setPhpName('CcPlaylist'); + $this->setClassname('CcPlaylist'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playlist_id_seq'); + // columns + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, ''); + $this->addColumn('STATE', 'DbState', 'VARCHAR', true, 128, 'empty'); + $this->addColumn('CURRENTLYACCESSING', 'DbCurrentlyaccessing', 'INTEGER', true, null, 0); + $this->addForeignKey('EDITEDBY', 'DbEditedby', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('CREATOR', 'DbCreator', 'VARCHAR', false, 32, null); + $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); + $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null); + } // buildRelations() + +} // CcPlaylistTableMap diff --git a/application/models/campcaster/map/CcPlaylistcontentsTableMap.php b/application/models/campcaster/map/CcPlaylistcontentsTableMap.php new file mode 100644 index 000000000..4ce59117e --- /dev/null +++ b/application/models/campcaster/map/CcPlaylistcontentsTableMap.php @@ -0,0 +1,62 @@ +setName('cc_playlistcontents'); + $this->setPhpName('CcPlaylistcontents'); + $this->setClassname('CcPlaylistcontents'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playlistcontents_id_seq'); + // columns + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', false, null, null); + $this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null); + $this->addColumn('POSITION', 'DbPosition', 'INTEGER', false, null, null); + $this->addColumn('CLIPLENGTH', 'DbCliplength', 'TIME', false, null, '00:00:00'); + $this->addColumn('CUEIN', 'DbCuein', 'TIME', false, null, '00:00:00'); + $this->addColumn('CUEOUT', 'DbCueout', 'TIME', false, null, '00:00:00'); + $this->addColumn('FADEIN', 'DbFadein', 'TIME', false, null, '00:00:00'); + $this->addColumn('FADEOUT', 'DbFadeout', 'TIME', false, null, '00:00:00'); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // CcPlaylistcontentsTableMap diff --git a/application/models/campcaster/map/CcPrefTableMap.php b/application/models/campcaster/map/CcPrefTableMap.php new file mode 100644 index 000000000..7bc77534e --- /dev/null +++ b/application/models/campcaster/map/CcPrefTableMap.php @@ -0,0 +1,56 @@ +setName('cc_pref'); + $this->setPhpName('CcPref'); + $this->setClassname('CcPref'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_pref_id_seq'); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('SUBJID', 'Subjid', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('KEYSTR', 'Keystr', 'VARCHAR', false, 255, null); + $this->addColumn('VALSTR', 'Valstr', 'LONGVARCHAR', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('subjid' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // CcPrefTableMap diff --git a/application/models/campcaster/map/CcScheduleTableMap.php b/application/models/campcaster/map/CcScheduleTableMap.php new file mode 100644 index 000000000..757998697 --- /dev/null +++ b/application/models/campcaster/map/CcScheduleTableMap.php @@ -0,0 +1,61 @@ +setName('cc_schedule'); + $this->setPhpName('CcSchedule'); + $this->setClassname('CcSchedule'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('ID', 'Id', 'BIGINT', true, null, null); + $this->addColumn('PLAYLIST_ID', 'PlaylistId', 'INTEGER', true, null, null); + $this->addColumn('STARTS', 'Starts', 'TIMESTAMP', true, null, null); + $this->addColumn('ENDS', 'Ends', 'TIMESTAMP', true, null, null); + $this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', false, null, null); + $this->addColumn('FILE_ID', 'FileId', 'INTEGER', false, null, null); + $this->addColumn('CLIP_LENGTH', 'ClipLength', 'TIME', false, null, '00:00:00'); + $this->addColumn('FADE_IN', 'FadeIn', 'TIME', false, null, '00:00:00'); + $this->addColumn('FADE_OUT', 'FadeOut', 'TIME', false, null, '00:00:00'); + $this->addColumn('CUE_IN', 'CueIn', 'TIME', false, null, '00:00:00'); + $this->addColumn('CUE_OUT', 'CueOut', 'TIME', false, null, '00:00:00'); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcScheduleTableMap diff --git a/application/models/campcaster/map/CcSessTableMap.php b/application/models/campcaster/map/CcSessTableMap.php new file mode 100644 index 000000000..8e928ab1c --- /dev/null +++ b/application/models/campcaster/map/CcSessTableMap.php @@ -0,0 +1,55 @@ +setName('cc_sess'); + $this->setPhpName('CcSess'); + $this->setClassname('CcSess'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('SESSID', 'Sessid', 'CHAR', true, 32, null); + $this->addForeignKey('USERID', 'Userid', 'INTEGER', 'cc_subjs', 'ID', false, null, null); + $this->addColumn('LOGIN', 'Login', 'VARCHAR', false, 255, null); + $this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('userid' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // CcSessTableMap diff --git a/application/models/campcaster/map/CcShowTableMap.php b/application/models/campcaster/map/CcShowTableMap.php new file mode 100644 index 000000000..4d927e35b --- /dev/null +++ b/application/models/campcaster/map/CcShowTableMap.php @@ -0,0 +1,60 @@ +setName('cc_show'); + $this->setPhpName('CcShow'); + $this->setClassname('CcShow'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_id_seq'); + // columns + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, ''); + $this->addColumn('FIRST_SHOW', 'DbFirstShow', 'DATE', true, null, null); + $this->addColumn('LAST_SHOW', 'DbLastShow', 'DATE', false, null, null); + $this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null); + $this->addColumn('END_TIME', 'DbEndTime', 'TIME', true, null, null); + $this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null); + $this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null); + $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcShowTableMap diff --git a/application/models/campcaster/map/CcSmembTableMap.php b/application/models/campcaster/map/CcSmembTableMap.php new file mode 100644 index 000000000..5cdb44df5 --- /dev/null +++ b/application/models/campcaster/map/CcSmembTableMap.php @@ -0,0 +1,55 @@ +setName('cc_smemb'); + $this->setPhpName('CcSmemb'); + $this->setClassname('CcSmemb'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('UID', 'Uid', 'INTEGER', true, null, 0); + $this->addColumn('GID', 'Gid', 'INTEGER', true, null, 0); + $this->addColumn('LEVEL', 'Level', 'INTEGER', true, null, 0); + $this->addColumn('MID', 'Mid', 'INTEGER', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcSmembTableMap diff --git a/application/models/campcaster/map/CcSubjsTableMap.php b/application/models/campcaster/map/CcSubjsTableMap.php new file mode 100644 index 000000000..a32bb2710 --- /dev/null +++ b/application/models/campcaster/map/CcSubjsTableMap.php @@ -0,0 +1,63 @@ +setName('cc_subjs'); + $this->setPhpName('CcSubjs'); + $this->setClassname('CcSubjs'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, ''); + $this->addColumn('PASS', 'Pass', 'VARCHAR', true, 255, ''); + $this->addColumn('TYPE', 'Type', 'CHAR', true, 1, 'U'); + $this->addColumn('REALNAME', 'Realname', 'VARCHAR', true, 255, ''); + $this->addColumn('LASTLOGIN', 'Lastlogin', 'TIMESTAMP', false, null, null); + $this->addColumn('LASTFAIL', 'Lastfail', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcAccess', 'CcAccess', RelationMap::ONE_TO_MANY, array('id' => 'owner', ), null, null); + $this->addRelation('CcFiles', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null); + $this->addRelation('CcPerms', 'CcPerms', RelationMap::ONE_TO_MANY, array('id' => 'subj', ), 'CASCADE', null); + $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null); + $this->addRelation('CcPref', 'CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null); + $this->addRelation('CcSess', 'CcSess', RelationMap::ONE_TO_MANY, array('id' => 'userid', ), 'CASCADE', null); + } // buildRelations() + +} // CcSubjsTableMap diff --git a/application/models/campcaster/map/CcTransTableMap.php b/application/models/campcaster/map/CcTransTableMap.php new file mode 100644 index 000000000..9ccb711db --- /dev/null +++ b/application/models/campcaster/map/CcTransTableMap.php @@ -0,0 +1,75 @@ +setName('cc_trans'); + $this->setPhpName('CcTrans'); + $this->setClassname('CcTrans'); + $this->setPackage('campcaster'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_trans_id_seq'); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('TRTOK', 'Trtok', 'CHAR', true, 16, null); + $this->addColumn('DIRECTION', 'Direction', 'VARCHAR', true, 128, null); + $this->addColumn('STATE', 'State', 'VARCHAR', true, 128, null); + $this->addColumn('TRTYPE', 'Trtype', 'VARCHAR', true, 128, null); + $this->addColumn('LOCK', 'Lock', 'CHAR', true, 1, 'N'); + $this->addColumn('TARGET', 'Target', 'VARCHAR', false, 255, null); + $this->addColumn('RTRTOK', 'Rtrtok', 'CHAR', false, 16, null); + $this->addColumn('MDTRTOK', 'Mdtrtok', 'CHAR', false, 16, null); + $this->addColumn('GUNID', 'Gunid', 'CHAR', false, 32, null); + $this->addColumn('PDTOKEN', 'Pdtoken', 'BIGINT', false, null, null); + $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null); + $this->addColumn('LOCALFILE', 'Localfile', 'VARCHAR', false, 255, null); + $this->addColumn('FNAME', 'Fname', 'VARCHAR', false, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('EXPECTEDSUM', 'Expectedsum', 'CHAR', false, 32, null); + $this->addColumn('REALSUM', 'Realsum', 'CHAR', false, 32, null); + $this->addColumn('EXPECTEDSIZE', 'Expectedsize', 'INTEGER', false, null, null); + $this->addColumn('REALSIZE', 'Realsize', 'INTEGER', false, null, null); + $this->addColumn('UID', 'Uid', 'INTEGER', false, null, null); + $this->addColumn('ERRMSG', 'Errmsg', 'VARCHAR', false, 255, null); + $this->addColumn('JOBPID', 'Jobpid', 'INTEGER', false, null, null); + $this->addColumn('START', 'Start', 'TIMESTAMP', false, null, null); + $this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcTransTableMap diff --git a/application/models/campcaster/om/BaseCcAccess.php b/application/models/campcaster/om/BaseCcAccess.php new file mode 100644 index 000000000..974682fed --- /dev/null +++ b/application/models/campcaster/om/BaseCcAccess.php @@ -0,0 +1,1236 @@ +chsum = ''; + $this->ext = ''; + $this->type = ''; + } + + /** + * Initializes internal state of BaseCcAccess object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Get the [gunid] column value. + * + * @return string + */ + public function getGunid() + { + return $this->gunid; + } + + /** + * Get the [token] column value. + * + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * Get the [chsum] column value. + * + * @return string + */ + public function getChsum() + { + return $this->chsum; + } + + /** + * Get the [ext] column value. + * + * @return string + */ + public function getExt() + { + return $this->ext; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Get the [parent] column value. + * + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Get the [owner] column value. + * + * @return int + */ + public function getOwner() + { + return $this->owner; + } + + /** + * Get the [optionally formatted] temporal [ts] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getTs($format = 'Y-m-d H:i:s') + { + if ($this->ts === null) { + return null; + } + + + + try { + $dt = new DateTime($this->ts); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ts, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcAccessPeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [gunid] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setGunid($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->gunid !== $v) { + $this->gunid = $v; + $this->modifiedColumns[] = CcAccessPeer::GUNID; + } + + return $this; + } // setGunid() + + /** + * Set the value of [token] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setToken($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->token !== $v) { + $this->token = $v; + $this->modifiedColumns[] = CcAccessPeer::TOKEN; + } + + return $this; + } // setToken() + + /** + * Set the value of [chsum] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setChsum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chsum !== $v || $this->isNew()) { + $this->chsum = $v; + $this->modifiedColumns[] = CcAccessPeer::CHSUM; + } + + return $this; + } // setChsum() + + /** + * Set the value of [ext] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setExt($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ext !== $v || $this->isNew()) { + $this->ext = $v; + $this->modifiedColumns[] = CcAccessPeer::EXT; + } + + return $this; + } // setExt() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v || $this->isNew()) { + $this->type = $v; + $this->modifiedColumns[] = CcAccessPeer::TYPE; + } + + return $this; + } // setType() + + /** + * Set the value of [parent] column. + * + * @param string $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setParent($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->parent !== $v) { + $this->parent = $v; + $this->modifiedColumns[] = CcAccessPeer::PARENT; + } + + return $this; + } // setParent() + + /** + * Set the value of [owner] column. + * + * @param int $v new value + * @return CcAccess The current object (for fluent API support) + */ + public function setOwner($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->owner !== $v) { + $this->owner = $v; + $this->modifiedColumns[] = CcAccessPeer::OWNER; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setOwner() + + /** + * Sets the value of [ts] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcAccess The current object (for fluent API support) + */ + public function setTs($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->ts !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->ts !== null && $tmpDt = new DateTime($this->ts)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->ts = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcAccessPeer::TS; + } + } // if either are not null + + return $this; + } // setTs() + + /** + * 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() + { + if ($this->chsum !== '') { + return false; + } + + if ($this->ext !== '') { + return false; + } + + if ($this->type !== '') { + return false; + } + + // 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->gunid = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->token = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->chsum = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->ext = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->type = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->parent = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->owner = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->ts = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = CcAccessPeer::NUM_COLUMNS - CcAccessPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcAccess 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->aCcSubjs !== null && $this->owner !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcAccessPeer::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 = CcAccessPeer::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->aCcSubjs = 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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcAccessQuery::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(CcAccessPeer::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); + CcAccessPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcAccessPeer::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(CcAccessPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcAccessPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcAccessPeer::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- for elements: 'required' | 'optional' | 'oneof'
+ *- for attributes: 'required' | 'implied' | 'normal'
+ *true
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcAccessPeer::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 = CcAccessPeer::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->getId(); + break; + case 1: + return $this->getGunid(); + break; + case 2: + return $this->getToken(); + break; + case 3: + return $this->getChsum(); + break; + case 4: + return $this->getExt(); + break; + case 5: + return $this->getType(); + break; + case 6: + return $this->getParent(); + break; + case 7: + return $this->getOwner(); + break; + case 8: + return $this->getTs(); + 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 = CcAccessPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getGunid(), + $keys[2] => $this->getToken(), + $keys[3] => $this->getChsum(), + $keys[4] => $this->getExt(), + $keys[5] => $this->getType(), + $keys[6] => $this->getParent(), + $keys[7] => $this->getOwner(), + $keys[8] => $this->getTs(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcAccessPeer::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->setId($value); + break; + case 1: + $this->setGunid($value); + break; + case 2: + $this->setToken($value); + break; + case 3: + $this->setChsum($value); + break; + case 4: + $this->setExt($value); + break; + case 5: + $this->setType($value); + break; + case 6: + $this->setParent($value); + break; + case 7: + $this->setOwner($value); + break; + case 8: + $this->setTs($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 = CcAccessPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setGunid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setToken($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setChsum($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setExt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setType($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setParent($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setOwner($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setTs($arr[$keys[8]]); + } + + /** + * 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(CcAccessPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcAccessPeer::ID)) $criteria->add(CcAccessPeer::ID, $this->id); + if ($this->isColumnModified(CcAccessPeer::GUNID)) $criteria->add(CcAccessPeer::GUNID, $this->gunid); + if ($this->isColumnModified(CcAccessPeer::TOKEN)) $criteria->add(CcAccessPeer::TOKEN, $this->token); + if ($this->isColumnModified(CcAccessPeer::CHSUM)) $criteria->add(CcAccessPeer::CHSUM, $this->chsum); + if ($this->isColumnModified(CcAccessPeer::EXT)) $criteria->add(CcAccessPeer::EXT, $this->ext); + if ($this->isColumnModified(CcAccessPeer::TYPE)) $criteria->add(CcAccessPeer::TYPE, $this->type); + if ($this->isColumnModified(CcAccessPeer::PARENT)) $criteria->add(CcAccessPeer::PARENT, $this->parent); + if ($this->isColumnModified(CcAccessPeer::OWNER)) $criteria->add(CcAccessPeer::OWNER, $this->owner); + if ($this->isColumnModified(CcAccessPeer::TS)) $criteria->add(CcAccessPeer::TS, $this->ts); + + 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(CcAccessPeer::DATABASE_NAME); + $criteria->add(CcAccessPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcAccess (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->setGunid($this->gunid); + $copyObj->setToken($this->token); + $copyObj->setChsum($this->chsum); + $copyObj->setExt($this->ext); + $copyObj->setType($this->type); + $copyObj->setParent($this->parent); + $copyObj->setOwner($this->owner); + $copyObj->setTs($this->ts); + + $copyObj->setNew(true); + $copyObj->setId(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 CcAccess 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 CcAccessPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcAccessPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcAccess The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwner(NULL); + } else { + $this->setOwner($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcAccess($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->owner !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner, $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->aCcSubjs->addCcAccesss($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->gunid = null; + $this->token = null; + $this->chsum = null; + $this->ext = null; + $this->type = null; + $this->parent = null; + $this->owner = null; + $this->ts = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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->aCcSubjs = 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); + } + +} // BaseCcAccess diff --git a/application/models/campcaster/om/BaseCcAccessPeer.php b/application/models/campcaster/om/BaseCcAccessPeer.php new file mode 100644 index 000000000..f6614d330 --- /dev/null +++ b/application/models/campcaster/om/BaseCcAccessPeer.php @@ -0,0 +1,1008 @@ + array ('Id', 'Gunid', 'Token', 'Chsum', 'Ext', 'Type', 'Parent', 'Owner', 'Ts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'gunid', 'token', 'chsum', 'ext', 'type', 'parent', 'owner', 'ts', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::GUNID, self::TOKEN, self::CHSUM, self::EXT, self::TYPE, self::PARENT, self::OWNER, self::TS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GUNID', 'TOKEN', 'CHSUM', 'EXT', 'TYPE', 'PARENT', 'OWNER', 'TS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'gunid', 'token', 'chsum', 'ext', 'type', 'parent', 'owner', 'ts', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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 ('Id' => 0, 'Gunid' => 1, 'Token' => 2, 'Chsum' => 3, 'Ext' => 4, 'Type' => 5, 'Parent' => 6, 'Owner' => 7, 'Ts' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'gunid' => 1, 'token' => 2, 'chsum' => 3, 'ext' => 4, 'type' => 5, 'parent' => 6, 'owner' => 7, 'ts' => 8, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::GUNID => 1, self::TOKEN => 2, self::CHSUM => 3, self::EXT => 4, self::TYPE => 5, self::PARENT => 6, self::OWNER => 7, self::TS => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GUNID' => 1, 'TOKEN' => 2, 'CHSUM' => 3, 'EXT' => 4, 'TYPE' => 5, 'PARENT' => 6, 'OWNER' => 7, 'TS' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'gunid' => 1, 'token' => 2, 'chsum' => 3, 'ext' => 4, 'type' => 5, 'parent' => 6, 'owner' => 7, 'ts' => 8, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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. CcAccessPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcAccessPeer::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(CcAccessPeer::ID); + $criteria->addSelectColumn(CcAccessPeer::GUNID); + $criteria->addSelectColumn(CcAccessPeer::TOKEN); + $criteria->addSelectColumn(CcAccessPeer::CHSUM); + $criteria->addSelectColumn(CcAccessPeer::EXT); + $criteria->addSelectColumn(CcAccessPeer::TYPE); + $criteria->addSelectColumn(CcAccessPeer::PARENT); + $criteria->addSelectColumn(CcAccessPeer::OWNER); + $criteria->addSelectColumn(CcAccessPeer::TS); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.GUNID'); + $criteria->addSelectColumn($alias . '.TOKEN'); + $criteria->addSelectColumn($alias . '.CHSUM'); + $criteria->addSelectColumn($alias . '.EXT'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.PARENT'); + $criteria->addSelectColumn($alias . '.OWNER'); + $criteria->addSelectColumn($alias . '.TS'); + } + } + + /** + * 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(CcAccessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcAccessPeer::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(CcAccessPeer::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 CcAccess + * @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 = CcAccessPeer::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 CcAccessPeer::populateObjects(CcAccessPeer::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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcAccessPeer::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 CcAccess $value A CcAccess object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcAccess $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcAccess object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcAccess) { + $key = (string) $value->getId(); + } 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 CcAccess 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 CcAccess 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_access + * 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 = CcAccessPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcAccessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcAccessPeer::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; + CcAccessPeer::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 (CcAccess object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcAccessPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcAccessPeer::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 + CcAccessPeer::NUM_COLUMNS; + } else { + $cls = CcAccessPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcAccessPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcAccessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcAccessPeer::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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcAccessPeer::OWNER, CcSubjsPeer::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 CcAccess objects pre-filled with their CcSubjs 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 CcAccess objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcAccessPeer::addSelectColumns($criteria); + $startcol = (CcAccessPeer::NUM_COLUMNS - CcAccessPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcAccessPeer::OWNER, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcAccessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcAccessPeer::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 = CcAccessPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcAccessPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcAccess) to $obj2 (CcSubjs) + $obj2->addCcAccess($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(CcAccessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcAccessPeer::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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcAccessPeer::OWNER, CcSubjsPeer::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 CcAccess 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 CcAccess 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); + } + + CcAccessPeer::addSelectColumns($criteria); + $startcol2 = (CcAccessPeer::NUM_COLUMNS - CcAccessPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcAccessPeer::OWNER, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcAccessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcAccessPeer::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 = CcAccessPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcAccessPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcAccess) to the collection in $obj2 (CcSubjs) + $obj2->addCcAccess($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(BaseCcAccessPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcAccessPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcAccessTableMap()); + } + } + + /** + * 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 ? CcAccessPeer::CLASS_DEFAULT : CcAccessPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcAccess or Criteria object. + * + * @param mixed $values Criteria or CcAccess 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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcAccess object + } + + if ($criteria->containsKey(CcAccessPeer::ID) && $criteria->keyContainsValue(CcAccessPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcAccessPeer::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 CcAccess or Criteria object. + * + * @param mixed $values Criteria or CcAccess 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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcAccessPeer::ID); + $value = $criteria->remove(CcAccessPeer::ID); + if ($value) { + $selectCriteria->add(CcAccessPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcAccessPeer::TABLE_NAME); + } + + } else { // $values is CcAccess 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_access 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(CcAccessPeer::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(CcAccessPeer::TABLE_NAME, $con, CcAccessPeer::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). + CcAccessPeer::clearInstancePool(); + CcAccessPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcAccess or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcAccess 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(CcAccessPeer::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. + CcAccessPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcAccess) { // it's a model object + // invalidate the cache for this single object + CcAccessPeer::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(CcAccessPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcAccessPeer::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); + CcAccessPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcAccess 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 CcAccess $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(CcAccess $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcAccessPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcAccessPeer::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(CcAccessPeer::DATABASE_NAME, CcAccessPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcAccess + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcAccessPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcAccessPeer::DATABASE_NAME); + $criteria->add(CcAccessPeer::ID, $pk); + + $v = CcAccessPeer::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(CcAccessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcAccessPeer::DATABASE_NAME); + $criteria->add(CcAccessPeer::ID, $pks, Criteria::IN); + $objs = CcAccessPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcAccessPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcAccessPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcAccessQuery.php b/application/models/campcaster/om/BaseCcAccessQuery.php new file mode 100644 index 000000000..d1e6b14c9 --- /dev/null +++ b/application/models/campcaster/om/BaseCcAccessQuery.php @@ -0,0 +1,477 @@ +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 CcAccess|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcAccessPeer::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 CcAccessQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcAccessPeer::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 CcAccessQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcAccessPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $id 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 CcAccessQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcAccessPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the gunid column + * + * @param string $gunid 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByGunid($gunid = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($gunid)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $gunid)) { + $gunid = str_replace('*', '%', $gunid); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcAccessPeer::GUNID, $gunid, $comparison); + } + + /** + * Filter the query on the token column + * + * @param string|array $token 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByToken($token = null, $comparison = null) + { + if (is_array($token)) { + $useMinMax = false; + if (isset($token['min'])) { + $this->addUsingAlias(CcAccessPeer::TOKEN, $token['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($token['max'])) { + $this->addUsingAlias(CcAccessPeer::TOKEN, $token['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcAccessPeer::TOKEN, $token, $comparison); + } + + /** + * Filter the query on the chsum column + * + * @param string $chsum 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByChsum($chsum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chsum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chsum)) { + $chsum = str_replace('*', '%', $chsum); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcAccessPeer::CHSUM, $chsum, $comparison); + } + + /** + * Filter the query on the ext column + * + * @param string $ext 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByExt($ext = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($ext)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $ext)) { + $ext = str_replace('*', '%', $ext); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcAccessPeer::EXT, $ext, $comparison); + } + + /** + * Filter the query on the type column + * + * @param string $type 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByType($type = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($type)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcAccessPeer::TYPE, $type, $comparison); + } + + /** + * Filter the query on the parent column + * + * @param string|array $parent 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByParent($parent = null, $comparison = null) + { + if (is_array($parent)) { + $useMinMax = false; + if (isset($parent['min'])) { + $this->addUsingAlias(CcAccessPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($parent['max'])) { + $this->addUsingAlias(CcAccessPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcAccessPeer::PARENT, $parent, $comparison); + } + + /** + * Filter the query on the owner column + * + * @param int|array $owner 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByOwner($owner = null, $comparison = null) + { + if (is_array($owner)) { + $useMinMax = false; + if (isset($owner['min'])) { + $this->addUsingAlias(CcAccessPeer::OWNER, $owner['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($owner['max'])) { + $this->addUsingAlias(CcAccessPeer::OWNER, $owner['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcAccessPeer::OWNER, $owner, $comparison); + } + + /** + * Filter the query on the ts column + * + * @param string|array $ts 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 CcAccessQuery The current query, for fluid interface + */ + public function filterByTs($ts = null, $comparison = null) + { + if (is_array($ts)) { + $useMinMax = false; + if (isset($ts['min'])) { + $this->addUsingAlias(CcAccessPeer::TS, $ts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ts['max'])) { + $this->addUsingAlias(CcAccessPeer::TS, $ts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcAccessPeer::TS, $ts, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcAccessQuery The current query, for fluid interface + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcAccessPeer::OWNER, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcAccessQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcAccess $ccAccess Object to remove from the list of results + * + * @return CcAccessQuery The current query, for fluid interface + */ + public function prune($ccAccess = null) + { + if ($ccAccess) { + $this->addUsingAlias(CcAccessPeer::ID, $ccAccess->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcAccessQuery diff --git a/application/models/campcaster/om/BaseCcBackup.php b/application/models/campcaster/om/BaseCcBackup.php new file mode 100644 index 000000000..37d8fb83b --- /dev/null +++ b/application/models/campcaster/om/BaseCcBackup.php @@ -0,0 +1,956 @@ +token; + } + + /** + * Get the [sessionid] column value. + * + * @return string + */ + public function getSessionid() + { + return $this->sessionid; + } + + /** + * Get the [status] column value. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Get the [optionally formatted] temporal [fromtime] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getFromtime($format = 'Y-m-d H:i:s') + { + if ($this->fromtime === null) { + return null; + } + + + + try { + $dt = new DateTime($this->fromtime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fromtime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [totime] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getTotime($format = 'Y-m-d H:i:s') + { + if ($this->totime === null) { + return null; + } + + + + try { + $dt = new DateTime($this->totime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->totime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [token] column. + * + * @param string $v new value + * @return CcBackup The current object (for fluent API support) + */ + public function setToken($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->token !== $v) { + $this->token = $v; + $this->modifiedColumns[] = CcBackupPeer::TOKEN; + } + + return $this; + } // setToken() + + /** + * Set the value of [sessionid] column. + * + * @param string $v new value + * @return CcBackup The current object (for fluent API support) + */ + public function setSessionid($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->sessionid !== $v) { + $this->sessionid = $v; + $this->modifiedColumns[] = CcBackupPeer::SESSIONID; + } + + return $this; + } // setSessionid() + + /** + * Set the value of [status] column. + * + * @param string $v new value + * @return CcBackup The current object (for fluent API support) + */ + public function setStatus($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->status !== $v) { + $this->status = $v; + $this->modifiedColumns[] = CcBackupPeer::STATUS; + } + + return $this; + } // setStatus() + + /** + * Sets the value of [fromtime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcBackup The current object (for fluent API support) + */ + public function setFromtime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->fromtime !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->fromtime !== null && $tmpDt = new DateTime($this->fromtime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->fromtime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcBackupPeer::FROMTIME; + } + } // if either are not null + + return $this; + } // setFromtime() + + /** + * Sets the value of [totime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcBackup The current object (for fluent API support) + */ + public function setTotime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->totime !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->totime !== null && $tmpDt = new DateTime($this->totime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->totime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcBackupPeer::TOTIME; + } + } // if either are not null + + return $this; + } // setTotime() + + /** + * 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->token = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->sessionid = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->status = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->fromtime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->totime = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = CcBackupPeer::NUM_COLUMNS - CcBackupPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcBackup 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() + { + + } // 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(CcBackupPeer::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 = CcBackupPeer::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? + + } // 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(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcBackupQuery::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(CcBackupPeer::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); + CcBackupPeer::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; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcBackupPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcBackupPeer::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 = CcBackupPeer::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->getToken(); + break; + case 1: + return $this->getSessionid(); + break; + case 2: + return $this->getStatus(); + break; + case 3: + return $this->getFromtime(); + break; + case 4: + return $this->getTotime(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcBackupPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getToken(), + $keys[1] => $this->getSessionid(), + $keys[2] => $this->getStatus(), + $keys[3] => $this->getFromtime(), + $keys[4] => $this->getTotime(), + ); + 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 = CcBackupPeer::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->setToken($value); + break; + case 1: + $this->setSessionid($value); + break; + case 2: + $this->setStatus($value); + break; + case 3: + $this->setFromtime($value); + break; + case 4: + $this->setTotime($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 = CcBackupPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setToken($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSessionid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setStatus($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setFromtime($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTotime($arr[$keys[4]]); + } + + /** + * 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(CcBackupPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcBackupPeer::TOKEN)) $criteria->add(CcBackupPeer::TOKEN, $this->token); + if ($this->isColumnModified(CcBackupPeer::SESSIONID)) $criteria->add(CcBackupPeer::SESSIONID, $this->sessionid); + if ($this->isColumnModified(CcBackupPeer::STATUS)) $criteria->add(CcBackupPeer::STATUS, $this->status); + if ($this->isColumnModified(CcBackupPeer::FROMTIME)) $criteria->add(CcBackupPeer::FROMTIME, $this->fromtime); + if ($this->isColumnModified(CcBackupPeer::TOTIME)) $criteria->add(CcBackupPeer::TOTIME, $this->totime); + + 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(CcBackupPeer::DATABASE_NAME); + $criteria->add(CcBackupPeer::TOKEN, $this->token); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getToken(); + } + + /** + * Generic method to set the primary key (token column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setToken($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getToken(); + } + + /** + * 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 CcBackup (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->setToken($this->token); + $copyObj->setSessionid($this->sessionid); + $copyObj->setStatus($this->status); + $copyObj->setFromtime($this->fromtime); + $copyObj->setTotime($this->totime); + + $copyObj->setNew(true); + } + + /** + * 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 CcBackup 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 CcBackupPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcBackupPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->token = null; + $this->sessionid = null; + $this->status = null; + $this->fromtime = null; + $this->totime = 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) + + } + + /** + * 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); + } + +} // BaseCcBackup diff --git a/application/models/campcaster/om/BaseCcBackupPeer.php b/application/models/campcaster/om/BaseCcBackupPeer.php new file mode 100644 index 000000000..b8c6a3066 --- /dev/null +++ b/application/models/campcaster/om/BaseCcBackupPeer.php @@ -0,0 +1,750 @@ + array ('Token', 'Sessionid', 'Status', 'Fromtime', 'Totime', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('token', 'sessionid', 'status', 'fromtime', 'totime', ), + BasePeer::TYPE_COLNAME => array (self::TOKEN, self::SESSIONID, self::STATUS, self::FROMTIME, self::TOTIME, ), + BasePeer::TYPE_RAW_COLNAME => array ('TOKEN', 'SESSIONID', 'STATUS', 'FROMTIME', 'TOTIME', ), + BasePeer::TYPE_FIELDNAME => array ('token', 'sessionid', 'status', 'fromtime', 'totime', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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 ('Token' => 0, 'Sessionid' => 1, 'Status' => 2, 'Fromtime' => 3, 'Totime' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('token' => 0, 'sessionid' => 1, 'status' => 2, 'fromtime' => 3, 'totime' => 4, ), + BasePeer::TYPE_COLNAME => array (self::TOKEN => 0, self::SESSIONID => 1, self::STATUS => 2, self::FROMTIME => 3, self::TOTIME => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('TOKEN' => 0, 'SESSIONID' => 1, 'STATUS' => 2, 'FROMTIME' => 3, 'TOTIME' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('token' => 0, 'sessionid' => 1, 'status' => 2, 'fromtime' => 3, 'totime' => 4, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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. CcBackupPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcBackupPeer::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(CcBackupPeer::TOKEN); + $criteria->addSelectColumn(CcBackupPeer::SESSIONID); + $criteria->addSelectColumn(CcBackupPeer::STATUS); + $criteria->addSelectColumn(CcBackupPeer::FROMTIME); + $criteria->addSelectColumn(CcBackupPeer::TOTIME); + } else { + $criteria->addSelectColumn($alias . '.TOKEN'); + $criteria->addSelectColumn($alias . '.SESSIONID'); + $criteria->addSelectColumn($alias . '.STATUS'); + $criteria->addSelectColumn($alias . '.FROMTIME'); + $criteria->addSelectColumn($alias . '.TOTIME'); + } + } + + /** + * 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(CcBackupPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBackupPeer::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(CcBackupPeer::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 CcBackup + * @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 = CcBackupPeer::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 CcBackupPeer::populateObjects(CcBackupPeer::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(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcBackupPeer::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 CcBackup $value A CcBackup object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcBackup $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getToken(); + } // 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 CcBackup object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcBackup) { + $key = (string) $value->getToken(); + } 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 CcBackup 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 CcBackup 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_backup + * 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 (string) $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 = CcBackupPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcBackupPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcBackupPeer::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; + CcBackupPeer::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 (CcBackup object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcBackupPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcBackupPeer::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 + CcBackupPeer::NUM_COLUMNS; + } else { + $cls = CcBackupPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcBackupPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcBackupPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcBackupPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcBackupTableMap()); + } + } + + /** + * 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 ? CcBackupPeer::CLASS_DEFAULT : CcBackupPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcBackup or Criteria object. + * + * @param mixed $values Criteria or CcBackup 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(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcBackup object + } + + + // 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 CcBackup or Criteria object. + * + * @param mixed $values Criteria or CcBackup 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(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcBackupPeer::TOKEN); + $value = $criteria->remove(CcBackupPeer::TOKEN); + if ($value) { + $selectCriteria->add(CcBackupPeer::TOKEN, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcBackupPeer::TABLE_NAME); + } + + } else { // $values is CcBackup 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_backup 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(CcBackupPeer::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(CcBackupPeer::TABLE_NAME, $con, CcBackupPeer::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). + CcBackupPeer::clearInstancePool(); + CcBackupPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcBackup or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcBackup 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(CcBackupPeer::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. + CcBackupPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcBackup) { // it's a model object + // invalidate the cache for this single object + CcBackupPeer::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(CcBackupPeer::TOKEN, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcBackupPeer::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); + CcBackupPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcBackup 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 CcBackup $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(CcBackup $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcBackupPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcBackupPeer::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(CcBackupPeer::DATABASE_NAME, CcBackupPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcBackup + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcBackupPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcBackupPeer::DATABASE_NAME); + $criteria->add(CcBackupPeer::TOKEN, $pk); + + $v = CcBackupPeer::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(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcBackupPeer::DATABASE_NAME); + $criteria->add(CcBackupPeer::TOKEN, $pks, Criteria::IN); + $objs = CcBackupPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcBackupPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcBackupPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcBackupQuery.php b/application/models/campcaster/om/BaseCcBackupQuery.php new file mode 100644 index 000000000..f74f068bf --- /dev/null +++ b/application/models/campcaster/om/BaseCcBackupQuery.php @@ -0,0 +1,292 @@ +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 CcBackup|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcBackupPeer::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 CcBackupQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcBackupPeer::TOKEN, $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 CcBackupQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcBackupPeer::TOKEN, $keys, Criteria::IN); + } + + /** + * Filter the query on the token column + * + * @param string $token 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 CcBackupQuery The current query, for fluid interface + */ + public function filterByToken($token = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($token)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $token)) { + $token = str_replace('*', '%', $token); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcBackupPeer::TOKEN, $token, $comparison); + } + + /** + * Filter the query on the sessionid column + * + * @param string $sessionid 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 CcBackupQuery The current query, for fluid interface + */ + public function filterBySessionid($sessionid = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($sessionid)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $sessionid)) { + $sessionid = str_replace('*', '%', $sessionid); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcBackupPeer::SESSIONID, $sessionid, $comparison); + } + + /** + * Filter the query on the status column + * + * @param string $status 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 CcBackupQuery The current query, for fluid interface + */ + public function filterByStatus($status = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($status)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $status)) { + $status = str_replace('*', '%', $status); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcBackupPeer::STATUS, $status, $comparison); + } + + /** + * Filter the query on the fromtime column + * + * @param string|array $fromtime 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 CcBackupQuery The current query, for fluid interface + */ + public function filterByFromtime($fromtime = null, $comparison = null) + { + if (is_array($fromtime)) { + $useMinMax = false; + if (isset($fromtime['min'])) { + $this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fromtime['max'])) { + $this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime, $comparison); + } + + /** + * Filter the query on the totime column + * + * @param string|array $totime 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 CcBackupQuery The current query, for fluid interface + */ + public function filterByTotime($totime = null, $comparison = null) + { + if (is_array($totime)) { + $useMinMax = false; + if (isset($totime['min'])) { + $this->addUsingAlias(CcBackupPeer::TOTIME, $totime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($totime['max'])) { + $this->addUsingAlias(CcBackupPeer::TOTIME, $totime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcBackupPeer::TOTIME, $totime, $comparison); + } + + /** + * Exclude object from result + * + * @param CcBackup $ccBackup Object to remove from the list of results + * + * @return CcBackupQuery The current query, for fluid interface + */ + public function prune($ccBackup = null) + { + if ($ccBackup) { + $this->addUsingAlias(CcBackupPeer::TOKEN, $ccBackup->getToken(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcBackupQuery diff --git a/application/models/campcaster/om/BaseCcFiles.php b/application/models/campcaster/om/BaseCcFiles.php new file mode 100644 index 000000000..94d732f04 --- /dev/null +++ b/application/models/campcaster/om/BaseCcFiles.php @@ -0,0 +1,3643 @@ +name = ''; + $this->mime = ''; + $this->ftype = ''; + $this->filepath = ''; + $this->state = 'empty'; + $this->currentlyaccessing = 0; + } + + /** + * Initializes internal state of BaseCcFiles object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + return $this->id; + } + + /** + * Get the [gunid] column value. + * + * @return string + */ + public function getGunid() + { + return $this->gunid; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get the [mime] column value. + * + * @return string + */ + public function getMime() + { + return $this->mime; + } + + /** + * Get the [ftype] column value. + * + * @return string + */ + public function getFtype() + { + return $this->ftype; + } + + /** + * Get the [filepath] column value. + * + * @return string + */ + public function getfilepath() + { + return $this->filepath; + } + + /** + * Get the [state] column value. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Get the [currentlyaccessing] column value. + * + * @return int + */ + public function getCurrentlyaccessing() + { + return $this->currentlyaccessing; + } + + /** + * Get the [editedby] column value. + * + * @return int + */ + public function getEditedby() + { + return $this->editedby; + } + + /** + * Get the [optionally formatted] temporal [mtime] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getMtime($format = 'Y-m-d H:i:s') + { + if ($this->mtime === null) { + return null; + } + + + + try { + $dt = new DateTime($this->mtime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [md5] column value. + * + * @return string + */ + public function getMd5() + { + return $this->md5; + } + + /** + * Get the [track_title] column value. + * + * @return string + */ + public function getTrackTitle() + { + return $this->track_title; + } + + /** + * Get the [artist_name] column value. + * + * @return string + */ + public function getArtistName() + { + return $this->artist_name; + } + + /** + * Get the [bit_rate] column value. + * + * @return string + */ + public function getBitRate() + { + return $this->bit_rate; + } + + /** + * Get the [sample_rate] column value. + * + * @return string + */ + public function getSampleRate() + { + return $this->sample_rate; + } + + /** + * Get the [format] column value. + * + * @return string + */ + public function getFormat() + { + return $this->format; + } + + /** + * Get the [optionally formatted] temporal [length] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbLength($format = '%X') + { + if ($this->length === null) { + return null; + } + + + + try { + $dt = new DateTime($this->length); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->length, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [album_title] column value. + * + * @return string + */ + public function getAlbumTitle() + { + return $this->album_title; + } + + /** + * Get the [genre] column value. + * + * @return string + */ + public function getGenre() + { + return $this->genre; + } + + /** + * Get the [comments] column value. + * + * @return string + */ + public function getComments() + { + return $this->comments; + } + + /** + * Get the [year] column value. + * + * @return string + */ + public function getYear() + { + return $this->year; + } + + /** + * Get the [track_number] column value. + * + * @return int + */ + public function getTrackNumber() + { + return $this->track_number; + } + + /** + * Get the [channels] column value. + * + * @return int + */ + public function getChannels() + { + return $this->channels; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Get the [bpm] column value. + * + * @return string + */ + public function getBpm() + { + return $this->bpm; + } + + /** + * Get the [rating] column value. + * + * @return string + */ + public function getRating() + { + return $this->rating; + } + + /** + * Get the [encoded_by] column value. + * + * @return string + */ + public function getEncodedBy() + { + return $this->encoded_by; + } + + /** + * Get the [disc_number] column value. + * + * @return string + */ + public function getDiscNumber() + { + return $this->disc_number; + } + + /** + * Get the [mood] column value. + * + * @return string + */ + public function getMood() + { + return $this->mood; + } + + /** + * Get the [label] column value. + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Get the [composer] column value. + * + * @return string + */ + public function getComposer() + { + return $this->composer; + } + + /** + * Get the [encoder] column value. + * + * @return string + */ + public function getEncoder() + { + return $this->encoder; + } + + /** + * Get the [checksum] column value. + * + * @return string + */ + public function getChecksum() + { + return $this->checksum; + } + + /** + * Get the [lyrics] column value. + * + * @return string + */ + public function getLyrics() + { + return $this->lyrics; + } + + /** + * Get the [orchestra] column value. + * + * @return string + */ + public function getOrchestra() + { + return $this->orchestra; + } + + /** + * Get the [conductor] column value. + * + * @return string + */ + public function getConductor() + { + return $this->conductor; + } + + /** + * Get the [lyricist] column value. + * + * @return string + */ + public function getLyricist() + { + return $this->lyricist; + } + + /** + * Get the [original_lyricist] column value. + * + * @return string + */ + public function getOriginalLyricist() + { + return $this->original_lyricist; + } + + /** + * Get the [radio_station_name] column value. + * + * @return string + */ + public function getRadioStationName() + { + return $this->radio_station_name; + } + + /** + * Get the [info_url] column value. + * + * @return string + */ + public function getInfoUrl() + { + return $this->info_url; + } + + /** + * Get the [artist_url] column value. + * + * @return string + */ + public function getArtistUrl() + { + return $this->artist_url; + } + + /** + * Get the [audio_source_url] column value. + * + * @return string + */ + public function getAudioSourceUrl() + { + return $this->audio_source_url; + } + + /** + * Get the [radio_station_url] column value. + * + * @return string + */ + public function getRadioStationUrl() + { + return $this->radio_station_url; + } + + /** + * Get the [buy_this_url] column value. + * + * @return string + */ + public function getBuyThisUrl() + { + return $this->buy_this_url; + } + + /** + * Get the [isrc_number] column value. + * + * @return string + */ + public function getIsrcNumber() + { + return $this->isrc_number; + } + + /** + * Get the [catalog_number] column value. + * + * @return string + */ + public function getCatalogNumber() + { + return $this->catalog_number; + } + + /** + * Get the [original_artist] column value. + * + * @return string + */ + public function getOriginalArtist() + { + return $this->original_artist; + } + + /** + * Get the [copyright] column value. + * + * @return string + */ + public function getCopyright() + { + return $this->copyright; + } + + /** + * Get the [report_datetime] column value. + * + * @return string + */ + public function getReportDatetime() + { + return $this->report_datetime; + } + + /** + * Get the [report_location] column value. + * + * @return string + */ + public function getReportLocation() + { + return $this->report_location; + } + + /** + * Get the [report_organization] column value. + * + * @return string + */ + public function getReportOrganization() + { + return $this->report_organization; + } + + /** + * Get the [subject] column value. + * + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Get the [contributor] column value. + * + * @return string + */ + public function getContributor() + { + return $this->contributor; + } + + /** + * Get the [language] column value. + * + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcFiles 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[] = CcFilesPeer::ID; + } + + return $this; + } // setDbId() + + /** + * Set the value of [gunid] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setGunid($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->gunid !== $v) { + $this->gunid = $v; + $this->modifiedColumns[] = CcFilesPeer::GUNID; + } + + return $this; + } // setGunid() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v || $this->isNew()) { + $this->name = $v; + $this->modifiedColumns[] = CcFilesPeer::NAME; + } + + return $this; + } // setName() + + /** + * Set the value of [mime] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setMime($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->mime !== $v || $this->isNew()) { + $this->mime = $v; + $this->modifiedColumns[] = CcFilesPeer::MIME; + } + + return $this; + } // setMime() + + /** + * Set the value of [ftype] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setFtype($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ftype !== $v || $this->isNew()) { + $this->ftype = $v; + $this->modifiedColumns[] = CcFilesPeer::FTYPE; + } + + return $this; + } // setFtype() + + /** + * Set the value of [filepath] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setfilepath($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->filepath !== $v || $this->isNew()) { + $this->filepath = $v; + $this->modifiedColumns[] = CcFilesPeer::FILEPATH; + } + + return $this; + } // setfilepath() + + /** + * Set the value of [state] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setState($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->state !== $v || $this->isNew()) { + $this->state = $v; + $this->modifiedColumns[] = CcFilesPeer::STATE; + } + + return $this; + } // setState() + + /** + * Set the value of [currentlyaccessing] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setCurrentlyaccessing($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->currentlyaccessing !== $v || $this->isNew()) { + $this->currentlyaccessing = $v; + $this->modifiedColumns[] = CcFilesPeer::CURRENTLYACCESSING; + } + + return $this; + } // setCurrentlyaccessing() + + /** + * Set the value of [editedby] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setEditedby($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->editedby !== $v) { + $this->editedby = $v; + $this->modifiedColumns[] = CcFilesPeer::EDITEDBY; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setEditedby() + + /** + * Sets the value of [mtime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcFiles The current object (for fluent API support) + */ + public function setMtime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->mtime !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->mtime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcFilesPeer::MTIME; + } + } // if either are not null + + return $this; + } // setMtime() + + /** + * Set the value of [md5] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setMd5($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->md5 !== $v) { + $this->md5 = $v; + $this->modifiedColumns[] = CcFilesPeer::MD5; + } + + return $this; + } // setMd5() + + /** + * Set the value of [track_title] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setTrackTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->track_title !== $v) { + $this->track_title = $v; + $this->modifiedColumns[] = CcFilesPeer::TRACK_TITLE; + } + + return $this; + } // setTrackTitle() + + /** + * Set the value of [artist_name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setArtistName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->artist_name !== $v) { + $this->artist_name = $v; + $this->modifiedColumns[] = CcFilesPeer::ARTIST_NAME; + } + + return $this; + } // setArtistName() + + /** + * Set the value of [bit_rate] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setBitRate($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->bit_rate !== $v) { + $this->bit_rate = $v; + $this->modifiedColumns[] = CcFilesPeer::BIT_RATE; + } + + return $this; + } // setBitRate() + + /** + * Set the value of [sample_rate] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setSampleRate($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->sample_rate !== $v) { + $this->sample_rate = $v; + $this->modifiedColumns[] = CcFilesPeer::SAMPLE_RATE; + } + + return $this; + } // setSampleRate() + + /** + * Set the value of [format] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setFormat($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->format !== $v) { + $this->format = $v; + $this->modifiedColumns[] = CcFilesPeer::FORMAT; + } + + return $this; + } // setFormat() + + /** + * Sets the value of [length] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLength($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->length !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->length !== null && $tmpDt = new DateTime($this->length)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->length = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcFilesPeer::LENGTH; + } + } // if either are not null + + return $this; + } // setDbLength() + + /** + * Set the value of [album_title] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setAlbumTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->album_title !== $v) { + $this->album_title = $v; + $this->modifiedColumns[] = CcFilesPeer::ALBUM_TITLE; + } + + return $this; + } // setAlbumTitle() + + /** + * Set the value of [genre] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setGenre($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->genre !== $v) { + $this->genre = $v; + $this->modifiedColumns[] = CcFilesPeer::GENRE; + } + + return $this; + } // setGenre() + + /** + * Set the value of [comments] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setComments($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->comments !== $v) { + $this->comments = $v; + $this->modifiedColumns[] = CcFilesPeer::COMMENTS; + } + + return $this; + } // setComments() + + /** + * Set the value of [year] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setYear($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->year !== $v) { + $this->year = $v; + $this->modifiedColumns[] = CcFilesPeer::YEAR; + } + + return $this; + } // setYear() + + /** + * Set the value of [track_number] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setTrackNumber($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->track_number !== $v) { + $this->track_number = $v; + $this->modifiedColumns[] = CcFilesPeer::TRACK_NUMBER; + } + + return $this; + } // setTrackNumber() + + /** + * Set the value of [channels] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setChannels($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->channels !== $v) { + $this->channels = $v; + $this->modifiedColumns[] = CcFilesPeer::CHANNELS; + } + + return $this; + } // setChannels() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = CcFilesPeer::URL; + } + + return $this; + } // setUrl() + + /** + * Set the value of [bpm] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setBpm($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->bpm !== $v) { + $this->bpm = $v; + $this->modifiedColumns[] = CcFilesPeer::BPM; + } + + return $this; + } // setBpm() + + /** + * Set the value of [rating] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setRating($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->rating !== $v) { + $this->rating = $v; + $this->modifiedColumns[] = CcFilesPeer::RATING; + } + + return $this; + } // setRating() + + /** + * Set the value of [encoded_by] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setEncodedBy($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->encoded_by !== $v) { + $this->encoded_by = $v; + $this->modifiedColumns[] = CcFilesPeer::ENCODED_BY; + } + + return $this; + } // setEncodedBy() + + /** + * Set the value of [disc_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDiscNumber($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->disc_number !== $v) { + $this->disc_number = $v; + $this->modifiedColumns[] = CcFilesPeer::DISC_NUMBER; + } + + return $this; + } // setDiscNumber() + + /** + * Set the value of [mood] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setMood($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->mood !== $v) { + $this->mood = $v; + $this->modifiedColumns[] = CcFilesPeer::MOOD; + } + + return $this; + } // setMood() + + /** + * Set the value of [label] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setLabel($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->label !== $v) { + $this->label = $v; + $this->modifiedColumns[] = CcFilesPeer::LABEL; + } + + return $this; + } // setLabel() + + /** + * Set the value of [composer] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setComposer($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->composer !== $v) { + $this->composer = $v; + $this->modifiedColumns[] = CcFilesPeer::COMPOSER; + } + + return $this; + } // setComposer() + + /** + * Set the value of [encoder] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setEncoder($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->encoder !== $v) { + $this->encoder = $v; + $this->modifiedColumns[] = CcFilesPeer::ENCODER; + } + + return $this; + } // setEncoder() + + /** + * Set the value of [checksum] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setChecksum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->checksum !== $v) { + $this->checksum = $v; + $this->modifiedColumns[] = CcFilesPeer::CHECKSUM; + } + + return $this; + } // setChecksum() + + /** + * Set the value of [lyrics] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setLyrics($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->lyrics !== $v) { + $this->lyrics = $v; + $this->modifiedColumns[] = CcFilesPeer::LYRICS; + } + + return $this; + } // setLyrics() + + /** + * Set the value of [orchestra] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setOrchestra($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->orchestra !== $v) { + $this->orchestra = $v; + $this->modifiedColumns[] = CcFilesPeer::ORCHESTRA; + } + + return $this; + } // setOrchestra() + + /** + * Set the value of [conductor] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setConductor($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->conductor !== $v) { + $this->conductor = $v; + $this->modifiedColumns[] = CcFilesPeer::CONDUCTOR; + } + + return $this; + } // setConductor() + + /** + * Set the value of [lyricist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setLyricist($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->lyricist !== $v) { + $this->lyricist = $v; + $this->modifiedColumns[] = CcFilesPeer::LYRICIST; + } + + return $this; + } // setLyricist() + + /** + * Set the value of [original_lyricist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setOriginalLyricist($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->original_lyricist !== $v) { + $this->original_lyricist = $v; + $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_LYRICIST; + } + + return $this; + } // setOriginalLyricist() + + /** + * Set the value of [radio_station_name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setRadioStationName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->radio_station_name !== $v) { + $this->radio_station_name = $v; + $this->modifiedColumns[] = CcFilesPeer::RADIO_STATION_NAME; + } + + return $this; + } // setRadioStationName() + + /** + * Set the value of [info_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setInfoUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->info_url !== $v) { + $this->info_url = $v; + $this->modifiedColumns[] = CcFilesPeer::INFO_URL; + } + + return $this; + } // setInfoUrl() + + /** + * Set the value of [artist_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setArtistUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->artist_url !== $v) { + $this->artist_url = $v; + $this->modifiedColumns[] = CcFilesPeer::ARTIST_URL; + } + + return $this; + } // setArtistUrl() + + /** + * Set the value of [audio_source_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setAudioSourceUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->audio_source_url !== $v) { + $this->audio_source_url = $v; + $this->modifiedColumns[] = CcFilesPeer::AUDIO_SOURCE_URL; + } + + return $this; + } // setAudioSourceUrl() + + /** + * Set the value of [radio_station_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setRadioStationUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->radio_station_url !== $v) { + $this->radio_station_url = $v; + $this->modifiedColumns[] = CcFilesPeer::RADIO_STATION_URL; + } + + return $this; + } // setRadioStationUrl() + + /** + * Set the value of [buy_this_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setBuyThisUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->buy_this_url !== $v) { + $this->buy_this_url = $v; + $this->modifiedColumns[] = CcFilesPeer::BUY_THIS_URL; + } + + return $this; + } // setBuyThisUrl() + + /** + * Set the value of [isrc_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setIsrcNumber($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->isrc_number !== $v) { + $this->isrc_number = $v; + $this->modifiedColumns[] = CcFilesPeer::ISRC_NUMBER; + } + + return $this; + } // setIsrcNumber() + + /** + * Set the value of [catalog_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setCatalogNumber($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->catalog_number !== $v) { + $this->catalog_number = $v; + $this->modifiedColumns[] = CcFilesPeer::CATALOG_NUMBER; + } + + return $this; + } // setCatalogNumber() + + /** + * Set the value of [original_artist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setOriginalArtist($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->original_artist !== $v) { + $this->original_artist = $v; + $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_ARTIST; + } + + return $this; + } // setOriginalArtist() + + /** + * Set the value of [copyright] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setCopyright($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->copyright !== $v) { + $this->copyright = $v; + $this->modifiedColumns[] = CcFilesPeer::COPYRIGHT; + } + + return $this; + } // setCopyright() + + /** + * Set the value of [report_datetime] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setReportDatetime($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->report_datetime !== $v) { + $this->report_datetime = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_DATETIME; + } + + return $this; + } // setReportDatetime() + + /** + * Set the value of [report_location] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setReportLocation($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->report_location !== $v) { + $this->report_location = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_LOCATION; + } + + return $this; + } // setReportLocation() + + /** + * Set the value of [report_organization] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setReportOrganization($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->report_organization !== $v) { + $this->report_organization = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_ORGANIZATION; + } + + return $this; + } // setReportOrganization() + + /** + * Set the value of [subject] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setSubject($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->subject !== $v) { + $this->subject = $v; + $this->modifiedColumns[] = CcFilesPeer::SUBJECT; + } + + return $this; + } // setSubject() + + /** + * Set the value of [contributor] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setContributor($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->contributor !== $v) { + $this->contributor = $v; + $this->modifiedColumns[] = CcFilesPeer::CONTRIBUTOR; + } + + return $this; + } // setContributor() + + /** + * Set the value of [language] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setLanguage($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->language !== $v) { + $this->language = $v; + $this->modifiedColumns[] = CcFilesPeer::LANGUAGE; + } + + return $this; + } // setLanguage() + + /** + * 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() + { + if ($this->name !== '') { + return false; + } + + if ($this->mime !== '') { + return false; + } + + if ($this->ftype !== '') { + return false; + } + + if ($this->filepath !== '') { + return false; + } + + if ($this->state !== 'empty') { + return false; + } + + if ($this->currentlyaccessing !== 0) { + return false; + } + + // 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->gunid = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->mime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->ftype = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->filepath = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->state = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->currentlyaccessing = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->editedby = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; + $this->mtime = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->md5 = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->track_title = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->artist_name = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; + $this->bit_rate = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; + $this->sample_rate = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; + $this->format = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; + $this->length = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; + $this->album_title = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; + $this->genre = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null; + $this->comments = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; + $this->year = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; + $this->track_number = ($row[$startcol + 21] !== null) ? (int) $row[$startcol + 21] : null; + $this->channels = ($row[$startcol + 22] !== null) ? (int) $row[$startcol + 22] : null; + $this->url = ($row[$startcol + 23] !== null) ? (string) $row[$startcol + 23] : null; + $this->bpm = ($row[$startcol + 24] !== null) ? (string) $row[$startcol + 24] : null; + $this->rating = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null; + $this->encoded_by = ($row[$startcol + 26] !== null) ? (string) $row[$startcol + 26] : null; + $this->disc_number = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null; + $this->mood = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null; + $this->label = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null; + $this->composer = ($row[$startcol + 30] !== null) ? (string) $row[$startcol + 30] : null; + $this->encoder = ($row[$startcol + 31] !== null) ? (string) $row[$startcol + 31] : null; + $this->checksum = ($row[$startcol + 32] !== null) ? (string) $row[$startcol + 32] : null; + $this->lyrics = ($row[$startcol + 33] !== null) ? (string) $row[$startcol + 33] : null; + $this->orchestra = ($row[$startcol + 34] !== null) ? (string) $row[$startcol + 34] : null; + $this->conductor = ($row[$startcol + 35] !== null) ? (string) $row[$startcol + 35] : null; + $this->lyricist = ($row[$startcol + 36] !== null) ? (string) $row[$startcol + 36] : null; + $this->original_lyricist = ($row[$startcol + 37] !== null) ? (string) $row[$startcol + 37] : null; + $this->radio_station_name = ($row[$startcol + 38] !== null) ? (string) $row[$startcol + 38] : null; + $this->info_url = ($row[$startcol + 39] !== null) ? (string) $row[$startcol + 39] : null; + $this->artist_url = ($row[$startcol + 40] !== null) ? (string) $row[$startcol + 40] : null; + $this->audio_source_url = ($row[$startcol + 41] !== null) ? (string) $row[$startcol + 41] : null; + $this->radio_station_url = ($row[$startcol + 42] !== null) ? (string) $row[$startcol + 42] : null; + $this->buy_this_url = ($row[$startcol + 43] !== null) ? (string) $row[$startcol + 43] : null; + $this->isrc_number = ($row[$startcol + 44] !== null) ? (string) $row[$startcol + 44] : null; + $this->catalog_number = ($row[$startcol + 45] !== null) ? (string) $row[$startcol + 45] : null; + $this->original_artist = ($row[$startcol + 46] !== null) ? (string) $row[$startcol + 46] : null; + $this->copyright = ($row[$startcol + 47] !== null) ? (string) $row[$startcol + 47] : null; + $this->report_datetime = ($row[$startcol + 48] !== null) ? (string) $row[$startcol + 48] : null; + $this->report_location = ($row[$startcol + 49] !== null) ? (string) $row[$startcol + 49] : null; + $this->report_organization = ($row[$startcol + 50] !== null) ? (string) $row[$startcol + 50] : null; + $this->subject = ($row[$startcol + 51] !== null) ? (string) $row[$startcol + 51] : null; + $this->contributor = ($row[$startcol + 52] !== null) ? (string) $row[$startcol + 52] : null; + $this->language = ($row[$startcol + 53] !== null) ? (string) $row[$startcol + 53] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 54; // 54 = CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcFiles 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->aCcSubjs !== null && $this->editedby !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcFilesPeer::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 = CcFilesPeer::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->aCcSubjs = null; + $this->collCcPlaylistcontentss = 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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcFilesQuery::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(CcFilesPeer::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); + CcFilesPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcFilesPeer::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(CcFilesPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcFilesPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcFilesPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcFilesPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $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 = CcFilesPeer::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->getGunid(); + break; + case 2: + return $this->getName(); + break; + case 3: + return $this->getMime(); + break; + case 4: + return $this->getFtype(); + break; + case 5: + return $this->getfilepath(); + break; + case 6: + return $this->getState(); + break; + case 7: + return $this->getCurrentlyaccessing(); + break; + case 8: + return $this->getEditedby(); + break; + case 9: + return $this->getMtime(); + break; + case 10: + return $this->getMd5(); + break; + case 11: + return $this->getTrackTitle(); + break; + case 12: + return $this->getArtistName(); + break; + case 13: + return $this->getBitRate(); + break; + case 14: + return $this->getSampleRate(); + break; + case 15: + return $this->getFormat(); + break; + case 16: + return $this->getDbLength(); + break; + case 17: + return $this->getAlbumTitle(); + break; + case 18: + return $this->getGenre(); + break; + case 19: + return $this->getComments(); + break; + case 20: + return $this->getYear(); + break; + case 21: + return $this->getTrackNumber(); + break; + case 22: + return $this->getChannels(); + break; + case 23: + return $this->getUrl(); + break; + case 24: + return $this->getBpm(); + break; + case 25: + return $this->getRating(); + break; + case 26: + return $this->getEncodedBy(); + break; + case 27: + return $this->getDiscNumber(); + break; + case 28: + return $this->getMood(); + break; + case 29: + return $this->getLabel(); + break; + case 30: + return $this->getComposer(); + break; + case 31: + return $this->getEncoder(); + break; + case 32: + return $this->getChecksum(); + break; + case 33: + return $this->getLyrics(); + break; + case 34: + return $this->getOrchestra(); + break; + case 35: + return $this->getConductor(); + break; + case 36: + return $this->getLyricist(); + break; + case 37: + return $this->getOriginalLyricist(); + break; + case 38: + return $this->getRadioStationName(); + break; + case 39: + return $this->getInfoUrl(); + break; + case 40: + return $this->getArtistUrl(); + break; + case 41: + return $this->getAudioSourceUrl(); + break; + case 42: + return $this->getRadioStationUrl(); + break; + case 43: + return $this->getBuyThisUrl(); + break; + case 44: + return $this->getIsrcNumber(); + break; + case 45: + return $this->getCatalogNumber(); + break; + case 46: + return $this->getOriginalArtist(); + break; + case 47: + return $this->getCopyright(); + break; + case 48: + return $this->getReportDatetime(); + break; + case 49: + return $this->getReportLocation(); + break; + case 50: + return $this->getReportOrganization(); + break; + case 51: + return $this->getSubject(); + break; + case 52: + return $this->getContributor(); + break; + case 53: + return $this->getLanguage(); + 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 = CcFilesPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getGunid(), + $keys[2] => $this->getName(), + $keys[3] => $this->getMime(), + $keys[4] => $this->getFtype(), + $keys[5] => $this->getfilepath(), + $keys[6] => $this->getState(), + $keys[7] => $this->getCurrentlyaccessing(), + $keys[8] => $this->getEditedby(), + $keys[9] => $this->getMtime(), + $keys[10] => $this->getMd5(), + $keys[11] => $this->getTrackTitle(), + $keys[12] => $this->getArtistName(), + $keys[13] => $this->getBitRate(), + $keys[14] => $this->getSampleRate(), + $keys[15] => $this->getFormat(), + $keys[16] => $this->getDbLength(), + $keys[17] => $this->getAlbumTitle(), + $keys[18] => $this->getGenre(), + $keys[19] => $this->getComments(), + $keys[20] => $this->getYear(), + $keys[21] => $this->getTrackNumber(), + $keys[22] => $this->getChannels(), + $keys[23] => $this->getUrl(), + $keys[24] => $this->getBpm(), + $keys[25] => $this->getRating(), + $keys[26] => $this->getEncodedBy(), + $keys[27] => $this->getDiscNumber(), + $keys[28] => $this->getMood(), + $keys[29] => $this->getLabel(), + $keys[30] => $this->getComposer(), + $keys[31] => $this->getEncoder(), + $keys[32] => $this->getChecksum(), + $keys[33] => $this->getLyrics(), + $keys[34] => $this->getOrchestra(), + $keys[35] => $this->getConductor(), + $keys[36] => $this->getLyricist(), + $keys[37] => $this->getOriginalLyricist(), + $keys[38] => $this->getRadioStationName(), + $keys[39] => $this->getInfoUrl(), + $keys[40] => $this->getArtistUrl(), + $keys[41] => $this->getAudioSourceUrl(), + $keys[42] => $this->getRadioStationUrl(), + $keys[43] => $this->getBuyThisUrl(), + $keys[44] => $this->getIsrcNumber(), + $keys[45] => $this->getCatalogNumber(), + $keys[46] => $this->getOriginalArtist(), + $keys[47] => $this->getCopyright(), + $keys[48] => $this->getReportDatetime(), + $keys[49] => $this->getReportLocation(), + $keys[50] => $this->getReportOrganization(), + $keys[51] => $this->getSubject(), + $keys[52] => $this->getContributor(), + $keys[53] => $this->getLanguage(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcFilesPeer::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->setGunid($value); + break; + case 2: + $this->setName($value); + break; + case 3: + $this->setMime($value); + break; + case 4: + $this->setFtype($value); + break; + case 5: + $this->setfilepath($value); + break; + case 6: + $this->setState($value); + break; + case 7: + $this->setCurrentlyaccessing($value); + break; + case 8: + $this->setEditedby($value); + break; + case 9: + $this->setMtime($value); + break; + case 10: + $this->setMd5($value); + break; + case 11: + $this->setTrackTitle($value); + break; + case 12: + $this->setArtistName($value); + break; + case 13: + $this->setBitRate($value); + break; + case 14: + $this->setSampleRate($value); + break; + case 15: + $this->setFormat($value); + break; + case 16: + $this->setDbLength($value); + break; + case 17: + $this->setAlbumTitle($value); + break; + case 18: + $this->setGenre($value); + break; + case 19: + $this->setComments($value); + break; + case 20: + $this->setYear($value); + break; + case 21: + $this->setTrackNumber($value); + break; + case 22: + $this->setChannels($value); + break; + case 23: + $this->setUrl($value); + break; + case 24: + $this->setBpm($value); + break; + case 25: + $this->setRating($value); + break; + case 26: + $this->setEncodedBy($value); + break; + case 27: + $this->setDiscNumber($value); + break; + case 28: + $this->setMood($value); + break; + case 29: + $this->setLabel($value); + break; + case 30: + $this->setComposer($value); + break; + case 31: + $this->setEncoder($value); + break; + case 32: + $this->setChecksum($value); + break; + case 33: + $this->setLyrics($value); + break; + case 34: + $this->setOrchestra($value); + break; + case 35: + $this->setConductor($value); + break; + case 36: + $this->setLyricist($value); + break; + case 37: + $this->setOriginalLyricist($value); + break; + case 38: + $this->setRadioStationName($value); + break; + case 39: + $this->setInfoUrl($value); + break; + case 40: + $this->setArtistUrl($value); + break; + case 41: + $this->setAudioSourceUrl($value); + break; + case 42: + $this->setRadioStationUrl($value); + break; + case 43: + $this->setBuyThisUrl($value); + break; + case 44: + $this->setIsrcNumber($value); + break; + case 45: + $this->setCatalogNumber($value); + break; + case 46: + $this->setOriginalArtist($value); + break; + case 47: + $this->setCopyright($value); + break; + case 48: + $this->setReportDatetime($value); + break; + case 49: + $this->setReportLocation($value); + break; + case 50: + $this->setReportOrganization($value); + break; + case 51: + $this->setSubject($value); + break; + case 52: + $this->setContributor($value); + break; + case 53: + $this->setLanguage($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 = CcFilesPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setGunid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setMime($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setFtype($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setfilepath($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setState($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setCurrentlyaccessing($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setEditedby($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setMtime($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setMd5($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setTrackTitle($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setArtistName($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setBitRate($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setSampleRate($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setFormat($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setDbLength($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setAlbumTitle($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setGenre($arr[$keys[18]]); + if (array_key_exists($keys[19], $arr)) $this->setComments($arr[$keys[19]]); + if (array_key_exists($keys[20], $arr)) $this->setYear($arr[$keys[20]]); + if (array_key_exists($keys[21], $arr)) $this->setTrackNumber($arr[$keys[21]]); + if (array_key_exists($keys[22], $arr)) $this->setChannels($arr[$keys[22]]); + if (array_key_exists($keys[23], $arr)) $this->setUrl($arr[$keys[23]]); + if (array_key_exists($keys[24], $arr)) $this->setBpm($arr[$keys[24]]); + if (array_key_exists($keys[25], $arr)) $this->setRating($arr[$keys[25]]); + if (array_key_exists($keys[26], $arr)) $this->setEncodedBy($arr[$keys[26]]); + if (array_key_exists($keys[27], $arr)) $this->setDiscNumber($arr[$keys[27]]); + if (array_key_exists($keys[28], $arr)) $this->setMood($arr[$keys[28]]); + if (array_key_exists($keys[29], $arr)) $this->setLabel($arr[$keys[29]]); + if (array_key_exists($keys[30], $arr)) $this->setComposer($arr[$keys[30]]); + if (array_key_exists($keys[31], $arr)) $this->setEncoder($arr[$keys[31]]); + if (array_key_exists($keys[32], $arr)) $this->setChecksum($arr[$keys[32]]); + if (array_key_exists($keys[33], $arr)) $this->setLyrics($arr[$keys[33]]); + if (array_key_exists($keys[34], $arr)) $this->setOrchestra($arr[$keys[34]]); + if (array_key_exists($keys[35], $arr)) $this->setConductor($arr[$keys[35]]); + if (array_key_exists($keys[36], $arr)) $this->setLyricist($arr[$keys[36]]); + if (array_key_exists($keys[37], $arr)) $this->setOriginalLyricist($arr[$keys[37]]); + if (array_key_exists($keys[38], $arr)) $this->setRadioStationName($arr[$keys[38]]); + if (array_key_exists($keys[39], $arr)) $this->setInfoUrl($arr[$keys[39]]); + if (array_key_exists($keys[40], $arr)) $this->setArtistUrl($arr[$keys[40]]); + if (array_key_exists($keys[41], $arr)) $this->setAudioSourceUrl($arr[$keys[41]]); + if (array_key_exists($keys[42], $arr)) $this->setRadioStationUrl($arr[$keys[42]]); + if (array_key_exists($keys[43], $arr)) $this->setBuyThisUrl($arr[$keys[43]]); + if (array_key_exists($keys[44], $arr)) $this->setIsrcNumber($arr[$keys[44]]); + if (array_key_exists($keys[45], $arr)) $this->setCatalogNumber($arr[$keys[45]]); + if (array_key_exists($keys[46], $arr)) $this->setOriginalArtist($arr[$keys[46]]); + if (array_key_exists($keys[47], $arr)) $this->setCopyright($arr[$keys[47]]); + if (array_key_exists($keys[48], $arr)) $this->setReportDatetime($arr[$keys[48]]); + if (array_key_exists($keys[49], $arr)) $this->setReportLocation($arr[$keys[49]]); + if (array_key_exists($keys[50], $arr)) $this->setReportOrganization($arr[$keys[50]]); + if (array_key_exists($keys[51], $arr)) $this->setSubject($arr[$keys[51]]); + if (array_key_exists($keys[52], $arr)) $this->setContributor($arr[$keys[52]]); + if (array_key_exists($keys[53], $arr)) $this->setLanguage($arr[$keys[53]]); + } + + /** + * 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(CcFilesPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcFilesPeer::ID)) $criteria->add(CcFilesPeer::ID, $this->id); + if ($this->isColumnModified(CcFilesPeer::GUNID)) $criteria->add(CcFilesPeer::GUNID, $this->gunid); + if ($this->isColumnModified(CcFilesPeer::NAME)) $criteria->add(CcFilesPeer::NAME, $this->name); + if ($this->isColumnModified(CcFilesPeer::MIME)) $criteria->add(CcFilesPeer::MIME, $this->mime); + if ($this->isColumnModified(CcFilesPeer::FTYPE)) $criteria->add(CcFilesPeer::FTYPE, $this->ftype); + if ($this->isColumnModified(CcFilesPeer::FILEPATH)) $criteria->add(CcFilesPeer::FILEPATH, $this->filepath); + if ($this->isColumnModified(CcFilesPeer::STATE)) $criteria->add(CcFilesPeer::STATE, $this->state); + if ($this->isColumnModified(CcFilesPeer::CURRENTLYACCESSING)) $criteria->add(CcFilesPeer::CURRENTLYACCESSING, $this->currentlyaccessing); + if ($this->isColumnModified(CcFilesPeer::EDITEDBY)) $criteria->add(CcFilesPeer::EDITEDBY, $this->editedby); + if ($this->isColumnModified(CcFilesPeer::MTIME)) $criteria->add(CcFilesPeer::MTIME, $this->mtime); + if ($this->isColumnModified(CcFilesPeer::MD5)) $criteria->add(CcFilesPeer::MD5, $this->md5); + if ($this->isColumnModified(CcFilesPeer::TRACK_TITLE)) $criteria->add(CcFilesPeer::TRACK_TITLE, $this->track_title); + if ($this->isColumnModified(CcFilesPeer::ARTIST_NAME)) $criteria->add(CcFilesPeer::ARTIST_NAME, $this->artist_name); + if ($this->isColumnModified(CcFilesPeer::BIT_RATE)) $criteria->add(CcFilesPeer::BIT_RATE, $this->bit_rate); + if ($this->isColumnModified(CcFilesPeer::SAMPLE_RATE)) $criteria->add(CcFilesPeer::SAMPLE_RATE, $this->sample_rate); + if ($this->isColumnModified(CcFilesPeer::FORMAT)) $criteria->add(CcFilesPeer::FORMAT, $this->format); + if ($this->isColumnModified(CcFilesPeer::LENGTH)) $criteria->add(CcFilesPeer::LENGTH, $this->length); + if ($this->isColumnModified(CcFilesPeer::ALBUM_TITLE)) $criteria->add(CcFilesPeer::ALBUM_TITLE, $this->album_title); + if ($this->isColumnModified(CcFilesPeer::GENRE)) $criteria->add(CcFilesPeer::GENRE, $this->genre); + if ($this->isColumnModified(CcFilesPeer::COMMENTS)) $criteria->add(CcFilesPeer::COMMENTS, $this->comments); + if ($this->isColumnModified(CcFilesPeer::YEAR)) $criteria->add(CcFilesPeer::YEAR, $this->year); + if ($this->isColumnModified(CcFilesPeer::TRACK_NUMBER)) $criteria->add(CcFilesPeer::TRACK_NUMBER, $this->track_number); + if ($this->isColumnModified(CcFilesPeer::CHANNELS)) $criteria->add(CcFilesPeer::CHANNELS, $this->channels); + if ($this->isColumnModified(CcFilesPeer::URL)) $criteria->add(CcFilesPeer::URL, $this->url); + if ($this->isColumnModified(CcFilesPeer::BPM)) $criteria->add(CcFilesPeer::BPM, $this->bpm); + if ($this->isColumnModified(CcFilesPeer::RATING)) $criteria->add(CcFilesPeer::RATING, $this->rating); + if ($this->isColumnModified(CcFilesPeer::ENCODED_BY)) $criteria->add(CcFilesPeer::ENCODED_BY, $this->encoded_by); + if ($this->isColumnModified(CcFilesPeer::DISC_NUMBER)) $criteria->add(CcFilesPeer::DISC_NUMBER, $this->disc_number); + if ($this->isColumnModified(CcFilesPeer::MOOD)) $criteria->add(CcFilesPeer::MOOD, $this->mood); + if ($this->isColumnModified(CcFilesPeer::LABEL)) $criteria->add(CcFilesPeer::LABEL, $this->label); + if ($this->isColumnModified(CcFilesPeer::COMPOSER)) $criteria->add(CcFilesPeer::COMPOSER, $this->composer); + if ($this->isColumnModified(CcFilesPeer::ENCODER)) $criteria->add(CcFilesPeer::ENCODER, $this->encoder); + if ($this->isColumnModified(CcFilesPeer::CHECKSUM)) $criteria->add(CcFilesPeer::CHECKSUM, $this->checksum); + if ($this->isColumnModified(CcFilesPeer::LYRICS)) $criteria->add(CcFilesPeer::LYRICS, $this->lyrics); + if ($this->isColumnModified(CcFilesPeer::ORCHESTRA)) $criteria->add(CcFilesPeer::ORCHESTRA, $this->orchestra); + if ($this->isColumnModified(CcFilesPeer::CONDUCTOR)) $criteria->add(CcFilesPeer::CONDUCTOR, $this->conductor); + if ($this->isColumnModified(CcFilesPeer::LYRICIST)) $criteria->add(CcFilesPeer::LYRICIST, $this->lyricist); + if ($this->isColumnModified(CcFilesPeer::ORIGINAL_LYRICIST)) $criteria->add(CcFilesPeer::ORIGINAL_LYRICIST, $this->original_lyricist); + if ($this->isColumnModified(CcFilesPeer::RADIO_STATION_NAME)) $criteria->add(CcFilesPeer::RADIO_STATION_NAME, $this->radio_station_name); + if ($this->isColumnModified(CcFilesPeer::INFO_URL)) $criteria->add(CcFilesPeer::INFO_URL, $this->info_url); + if ($this->isColumnModified(CcFilesPeer::ARTIST_URL)) $criteria->add(CcFilesPeer::ARTIST_URL, $this->artist_url); + if ($this->isColumnModified(CcFilesPeer::AUDIO_SOURCE_URL)) $criteria->add(CcFilesPeer::AUDIO_SOURCE_URL, $this->audio_source_url); + if ($this->isColumnModified(CcFilesPeer::RADIO_STATION_URL)) $criteria->add(CcFilesPeer::RADIO_STATION_URL, $this->radio_station_url); + if ($this->isColumnModified(CcFilesPeer::BUY_THIS_URL)) $criteria->add(CcFilesPeer::BUY_THIS_URL, $this->buy_this_url); + if ($this->isColumnModified(CcFilesPeer::ISRC_NUMBER)) $criteria->add(CcFilesPeer::ISRC_NUMBER, $this->isrc_number); + if ($this->isColumnModified(CcFilesPeer::CATALOG_NUMBER)) $criteria->add(CcFilesPeer::CATALOG_NUMBER, $this->catalog_number); + if ($this->isColumnModified(CcFilesPeer::ORIGINAL_ARTIST)) $criteria->add(CcFilesPeer::ORIGINAL_ARTIST, $this->original_artist); + if ($this->isColumnModified(CcFilesPeer::COPYRIGHT)) $criteria->add(CcFilesPeer::COPYRIGHT, $this->copyright); + if ($this->isColumnModified(CcFilesPeer::REPORT_DATETIME)) $criteria->add(CcFilesPeer::REPORT_DATETIME, $this->report_datetime); + if ($this->isColumnModified(CcFilesPeer::REPORT_LOCATION)) $criteria->add(CcFilesPeer::REPORT_LOCATION, $this->report_location); + if ($this->isColumnModified(CcFilesPeer::REPORT_ORGANIZATION)) $criteria->add(CcFilesPeer::REPORT_ORGANIZATION, $this->report_organization); + if ($this->isColumnModified(CcFilesPeer::SUBJECT)) $criteria->add(CcFilesPeer::SUBJECT, $this->subject); + if ($this->isColumnModified(CcFilesPeer::CONTRIBUTOR)) $criteria->add(CcFilesPeer::CONTRIBUTOR, $this->contributor); + if ($this->isColumnModified(CcFilesPeer::LANGUAGE)) $criteria->add(CcFilesPeer::LANGUAGE, $this->language); + + 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(CcFilesPeer::DATABASE_NAME); + $criteria->add(CcFilesPeer::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 CcFiles (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->setGunid($this->gunid); + $copyObj->setName($this->name); + $copyObj->setMime($this->mime); + $copyObj->setFtype($this->ftype); + $copyObj->setfilepath($this->filepath); + $copyObj->setState($this->state); + $copyObj->setCurrentlyaccessing($this->currentlyaccessing); + $copyObj->setEditedby($this->editedby); + $copyObj->setMtime($this->mtime); + $copyObj->setMd5($this->md5); + $copyObj->setTrackTitle($this->track_title); + $copyObj->setArtistName($this->artist_name); + $copyObj->setBitRate($this->bit_rate); + $copyObj->setSampleRate($this->sample_rate); + $copyObj->setFormat($this->format); + $copyObj->setDbLength($this->length); + $copyObj->setAlbumTitle($this->album_title); + $copyObj->setGenre($this->genre); + $copyObj->setComments($this->comments); + $copyObj->setYear($this->year); + $copyObj->setTrackNumber($this->track_number); + $copyObj->setChannels($this->channels); + $copyObj->setUrl($this->url); + $copyObj->setBpm($this->bpm); + $copyObj->setRating($this->rating); + $copyObj->setEncodedBy($this->encoded_by); + $copyObj->setDiscNumber($this->disc_number); + $copyObj->setMood($this->mood); + $copyObj->setLabel($this->label); + $copyObj->setComposer($this->composer); + $copyObj->setEncoder($this->encoder); + $copyObj->setChecksum($this->checksum); + $copyObj->setLyrics($this->lyrics); + $copyObj->setOrchestra($this->orchestra); + $copyObj->setConductor($this->conductor); + $copyObj->setLyricist($this->lyricist); + $copyObj->setOriginalLyricist($this->original_lyricist); + $copyObj->setRadioStationName($this->radio_station_name); + $copyObj->setInfoUrl($this->info_url); + $copyObj->setArtistUrl($this->artist_url); + $copyObj->setAudioSourceUrl($this->audio_source_url); + $copyObj->setRadioStationUrl($this->radio_station_url); + $copyObj->setBuyThisUrl($this->buy_this_url); + $copyObj->setIsrcNumber($this->isrc_number); + $copyObj->setCatalogNumber($this->catalog_number); + $copyObj->setOriginalArtist($this->original_artist); + $copyObj->setCopyright($this->copyright); + $copyObj->setReportDatetime($this->report_datetime); + $copyObj->setReportLocation($this->report_location); + $copyObj->setReportOrganization($this->report_organization); + $copyObj->setSubject($this->subject); + $copyObj->setContributor($this->contributor); + $copyObj->setLanguage($this->language); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCcPlaylistcontentss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlaylistcontents($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + + $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 CcFiles 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 CcFilesPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcFilesPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcFiles The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setEditedby(NULL); + } else { + $this->setEditedby($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcFiles($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->editedby !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->editedby, $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->aCcSubjs->addCcFiless($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears out the collCcPlaylistcontentss 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 addCcPlaylistcontentss() + */ + public function clearCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcPlaylistcontentss collection. + * + * By default this just sets the collCcPlaylistcontentss collection to an empty array (like clearcollCcPlaylistcontentss()); + * 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 initCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = new PropelObjectCollection(); + $this->collCcPlaylistcontentss->setModel('CcPlaylistcontents'); + } + + /** + * Gets an array of CcPlaylistcontents 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 CcFiles 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 CcPlaylistcontents[] List of CcPlaylistcontents objects + * @throws PropelException + */ + public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcPlaylistcontentss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + // return empty collection + $this->initCcPlaylistcontentss(); + } else { + $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + return $collCcPlaylistcontentss; + } + $this->collCcPlaylistcontentss = $collCcPlaylistcontentss; + } + } + return $this->collCcPlaylistcontentss; + } + + /** + * Returns the number of related CcPlaylistcontents objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlaylistcontents objects. + * @throws PropelException + */ + public function countCcPlaylistcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcPlaylistcontentss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + return 0; + } else { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcFiles($this) + ->count($con); + } + } else { + return count($this->collCcPlaylistcontentss); + } + } + + /** + * Method called to associate a CcPlaylistcontents object to this object + * through the CcPlaylistcontents foreign key attribute. + * + * @param CcPlaylistcontents $l CcPlaylistcontents + * @return void + * @throws PropelException + */ + public function addCcPlaylistcontents(CcPlaylistcontents $l) + { + if ($this->collCcPlaylistcontentss === null) { + $this->initCcPlaylistcontentss(); + } + if (!$this->collCcPlaylistcontentss->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcPlaylistcontentss[]= $l; + $l->setCcFiles($this); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcFiles is new, it will return + * an empty collection; or if this CcFiles has previously + * been saved, it will retrieve related CcPlaylistcontentss from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcFiles. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects + */ + public function getCcPlaylistcontentssJoinCcPlaylist($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + $query->joinWith('CcPlaylist', $join_behavior); + + return $this->getCcPlaylistcontentss($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->gunid = null; + $this->name = null; + $this->mime = null; + $this->ftype = null; + $this->filepath = null; + $this->state = null; + $this->currentlyaccessing = null; + $this->editedby = null; + $this->mtime = null; + $this->md5 = null; + $this->track_title = null; + $this->artist_name = null; + $this->bit_rate = null; + $this->sample_rate = null; + $this->format = null; + $this->length = null; + $this->album_title = null; + $this->genre = null; + $this->comments = null; + $this->year = null; + $this->track_number = null; + $this->channels = null; + $this->url = null; + $this->bpm = null; + $this->rating = null; + $this->encoded_by = null; + $this->disc_number = null; + $this->mood = null; + $this->label = null; + $this->composer = null; + $this->encoder = null; + $this->checksum = null; + $this->lyrics = null; + $this->orchestra = null; + $this->conductor = null; + $this->lyricist = null; + $this->original_lyricist = null; + $this->radio_station_name = null; + $this->info_url = null; + $this->artist_url = null; + $this->audio_source_url = null; + $this->radio_station_url = null; + $this->buy_this_url = null; + $this->isrc_number = null; + $this->catalog_number = null; + $this->original_artist = null; + $this->copyright = null; + $this->report_datetime = null; + $this->report_location = null; + $this->report_organization = null; + $this->subject = null; + $this->contributor = null; + $this->language = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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 ($this->collCcPlaylistcontentss) { + foreach ((array) $this->collCcPlaylistcontentss as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + $this->collCcPlaylistcontentss = null; + $this->aCcSubjs = 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); + } + +} // BaseCcFiles diff --git a/application/models/campcaster/om/BaseCcFilesPeer.php b/application/models/campcaster/om/BaseCcFilesPeer.php new file mode 100644 index 000000000..8f48b5fc9 --- /dev/null +++ b/application/models/campcaster/om/BaseCcFilesPeer.php @@ -0,0 +1,1236 @@ + array ('DbId', 'Gunid', 'Name', 'Mime', 'Ftype', 'filepath', 'State', 'Currentlyaccessing', 'Editedby', 'Mtime', 'Md5', 'TrackTitle', 'ArtistName', 'BitRate', 'SampleRate', 'Format', 'DbLength', 'AlbumTitle', 'Genre', 'Comments', 'Year', 'TrackNumber', 'Channels', 'Url', 'Bpm', 'Rating', 'EncodedBy', 'DiscNumber', 'Mood', 'Label', 'Composer', 'Encoder', 'Checksum', 'Lyrics', 'Orchestra', 'Conductor', 'Lyricist', 'OriginalLyricist', 'RadioStationName', 'InfoUrl', 'ArtistUrl', 'AudioSourceUrl', 'RadioStationUrl', 'BuyThisUrl', 'IsrcNumber', 'CatalogNumber', 'OriginalArtist', 'Copyright', 'ReportDatetime', 'ReportLocation', 'ReportOrganization', 'Subject', 'Contributor', 'Language', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'gunid', 'name', 'mime', 'ftype', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'md5', 'trackTitle', 'artistName', 'bitRate', 'sampleRate', 'format', 'dbLength', 'albumTitle', 'genre', 'comments', 'year', 'trackNumber', 'channels', 'url', 'bpm', 'rating', 'encodedBy', 'discNumber', 'mood', 'label', 'composer', 'encoder', 'checksum', 'lyrics', 'orchestra', 'conductor', 'lyricist', 'originalLyricist', 'radioStationName', 'infoUrl', 'artistUrl', 'audioSourceUrl', 'radioStationUrl', 'buyThisUrl', 'isrcNumber', 'catalogNumber', 'originalArtist', 'copyright', 'reportDatetime', 'reportLocation', 'reportOrganization', 'subject', 'contributor', 'language', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::GUNID, self::NAME, self::MIME, self::FTYPE, self::FILEPATH, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::MD5, self::TRACK_TITLE, self::ARTIST_NAME, self::BIT_RATE, self::SAMPLE_RATE, self::FORMAT, self::LENGTH, self::ALBUM_TITLE, self::GENRE, self::COMMENTS, self::YEAR, self::TRACK_NUMBER, self::CHANNELS, self::URL, self::BPM, self::RATING, self::ENCODED_BY, self::DISC_NUMBER, self::MOOD, self::LABEL, self::COMPOSER, self::ENCODER, self::CHECKSUM, self::LYRICS, self::ORCHESTRA, self::CONDUCTOR, self::LYRICIST, self::ORIGINAL_LYRICIST, self::RADIO_STATION_NAME, self::INFO_URL, self::ARTIST_URL, self::AUDIO_SOURCE_URL, self::RADIO_STATION_URL, self::BUY_THIS_URL, self::ISRC_NUMBER, self::CATALOG_NUMBER, self::ORIGINAL_ARTIST, self::COPYRIGHT, self::REPORT_DATETIME, self::REPORT_LOCATION, self::REPORT_ORGANIZATION, self::SUBJECT, self::CONTRIBUTOR, self::LANGUAGE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GUNID', 'NAME', 'MIME', 'FTYPE', 'FILEPATH', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'MD5', 'TRACK_TITLE', 'ARTIST_NAME', 'BIT_RATE', 'SAMPLE_RATE', 'FORMAT', 'LENGTH', 'ALBUM_TITLE', 'GENRE', 'COMMENTS', 'YEAR', 'TRACK_NUMBER', 'CHANNELS', 'URL', 'BPM', 'RATING', 'ENCODED_BY', 'DISC_NUMBER', 'MOOD', 'LABEL', 'COMPOSER', 'ENCODER', 'CHECKSUM', 'LYRICS', 'ORCHESTRA', 'CONDUCTOR', 'LYRICIST', 'ORIGINAL_LYRICIST', 'RADIO_STATION_NAME', 'INFO_URL', 'ARTIST_URL', 'AUDIO_SOURCE_URL', 'RADIO_STATION_URL', 'BUY_THIS_URL', 'ISRC_NUMBER', 'CATALOG_NUMBER', 'ORIGINAL_ARTIST', 'COPYRIGHT', 'REPORT_DATETIME', 'REPORT_LOCATION', 'REPORT_ORGANIZATION', 'SUBJECT', 'CONTRIBUTOR', 'LANGUAGE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'gunid', 'name', 'mime', 'ftype', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'md5', 'track_title', 'artist_name', 'bit_rate', 'sample_rate', 'format', 'length', 'album_title', 'genre', 'comments', 'year', 'track_number', 'channels', 'url', 'bpm', 'rating', 'encoded_by', 'disc_number', 'mood', 'label', 'composer', 'encoder', 'checksum', 'lyrics', 'orchestra', 'conductor', 'lyricist', 'original_lyricist', 'radio_station_name', 'info_url', 'artist_url', 'audio_source_url', 'radio_station_url', 'buy_this_url', 'isrc_number', 'catalog_number', 'original_artist', 'copyright', 'report_datetime', 'report_location', 'report_organization', 'subject', 'contributor', 'language', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, ) + ); + + /** + * 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, 'Gunid' => 1, 'Name' => 2, 'Mime' => 3, 'Ftype' => 4, 'filepath' => 5, 'State' => 6, 'Currentlyaccessing' => 7, 'Editedby' => 8, 'Mtime' => 9, 'Md5' => 10, 'TrackTitle' => 11, 'ArtistName' => 12, 'BitRate' => 13, 'SampleRate' => 14, 'Format' => 15, 'DbLength' => 16, 'AlbumTitle' => 17, 'Genre' => 18, 'Comments' => 19, 'Year' => 20, 'TrackNumber' => 21, 'Channels' => 22, 'Url' => 23, 'Bpm' => 24, 'Rating' => 25, 'EncodedBy' => 26, 'DiscNumber' => 27, 'Mood' => 28, 'Label' => 29, 'Composer' => 30, 'Encoder' => 31, 'Checksum' => 32, 'Lyrics' => 33, 'Orchestra' => 34, 'Conductor' => 35, 'Lyricist' => 36, 'OriginalLyricist' => 37, 'RadioStationName' => 38, 'InfoUrl' => 39, 'ArtistUrl' => 40, 'AudioSourceUrl' => 41, 'RadioStationUrl' => 42, 'BuyThisUrl' => 43, 'IsrcNumber' => 44, 'CatalogNumber' => 45, 'OriginalArtist' => 46, 'Copyright' => 47, 'ReportDatetime' => 48, 'ReportLocation' => 49, 'ReportOrganization' => 50, 'Subject' => 51, 'Contributor' => 52, 'Language' => 53, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'gunid' => 1, 'name' => 2, 'mime' => 3, 'ftype' => 4, 'filepath' => 5, 'state' => 6, 'currentlyaccessing' => 7, 'editedby' => 8, 'mtime' => 9, 'md5' => 10, 'trackTitle' => 11, 'artistName' => 12, 'bitRate' => 13, 'sampleRate' => 14, 'format' => 15, 'dbLength' => 16, 'albumTitle' => 17, 'genre' => 18, 'comments' => 19, 'year' => 20, 'trackNumber' => 21, 'channels' => 22, 'url' => 23, 'bpm' => 24, 'rating' => 25, 'encodedBy' => 26, 'discNumber' => 27, 'mood' => 28, 'label' => 29, 'composer' => 30, 'encoder' => 31, 'checksum' => 32, 'lyrics' => 33, 'orchestra' => 34, 'conductor' => 35, 'lyricist' => 36, 'originalLyricist' => 37, 'radioStationName' => 38, 'infoUrl' => 39, 'artistUrl' => 40, 'audioSourceUrl' => 41, 'radioStationUrl' => 42, 'buyThisUrl' => 43, 'isrcNumber' => 44, 'catalogNumber' => 45, 'originalArtist' => 46, 'copyright' => 47, 'reportDatetime' => 48, 'reportLocation' => 49, 'reportOrganization' => 50, 'subject' => 51, 'contributor' => 52, 'language' => 53, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::GUNID => 1, self::NAME => 2, self::MIME => 3, self::FTYPE => 4, self::FILEPATH => 5, self::STATE => 6, self::CURRENTLYACCESSING => 7, self::EDITEDBY => 8, self::MTIME => 9, self::MD5 => 10, self::TRACK_TITLE => 11, self::ARTIST_NAME => 12, self::BIT_RATE => 13, self::SAMPLE_RATE => 14, self::FORMAT => 15, self::LENGTH => 16, self::ALBUM_TITLE => 17, self::GENRE => 18, self::COMMENTS => 19, self::YEAR => 20, self::TRACK_NUMBER => 21, self::CHANNELS => 22, self::URL => 23, self::BPM => 24, self::RATING => 25, self::ENCODED_BY => 26, self::DISC_NUMBER => 27, self::MOOD => 28, self::LABEL => 29, self::COMPOSER => 30, self::ENCODER => 31, self::CHECKSUM => 32, self::LYRICS => 33, self::ORCHESTRA => 34, self::CONDUCTOR => 35, self::LYRICIST => 36, self::ORIGINAL_LYRICIST => 37, self::RADIO_STATION_NAME => 38, self::INFO_URL => 39, self::ARTIST_URL => 40, self::AUDIO_SOURCE_URL => 41, self::RADIO_STATION_URL => 42, self::BUY_THIS_URL => 43, self::ISRC_NUMBER => 44, self::CATALOG_NUMBER => 45, self::ORIGINAL_ARTIST => 46, self::COPYRIGHT => 47, self::REPORT_DATETIME => 48, self::REPORT_LOCATION => 49, self::REPORT_ORGANIZATION => 50, self::SUBJECT => 51, self::CONTRIBUTOR => 52, self::LANGUAGE => 53, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GUNID' => 1, 'NAME' => 2, 'MIME' => 3, 'FTYPE' => 4, 'FILEPATH' => 5, 'STATE' => 6, 'CURRENTLYACCESSING' => 7, 'EDITEDBY' => 8, 'MTIME' => 9, 'MD5' => 10, 'TRACK_TITLE' => 11, 'ARTIST_NAME' => 12, 'BIT_RATE' => 13, 'SAMPLE_RATE' => 14, 'FORMAT' => 15, 'LENGTH' => 16, 'ALBUM_TITLE' => 17, 'GENRE' => 18, 'COMMENTS' => 19, 'YEAR' => 20, 'TRACK_NUMBER' => 21, 'CHANNELS' => 22, 'URL' => 23, 'BPM' => 24, 'RATING' => 25, 'ENCODED_BY' => 26, 'DISC_NUMBER' => 27, 'MOOD' => 28, 'LABEL' => 29, 'COMPOSER' => 30, 'ENCODER' => 31, 'CHECKSUM' => 32, 'LYRICS' => 33, 'ORCHESTRA' => 34, 'CONDUCTOR' => 35, 'LYRICIST' => 36, 'ORIGINAL_LYRICIST' => 37, 'RADIO_STATION_NAME' => 38, 'INFO_URL' => 39, 'ARTIST_URL' => 40, 'AUDIO_SOURCE_URL' => 41, 'RADIO_STATION_URL' => 42, 'BUY_THIS_URL' => 43, 'ISRC_NUMBER' => 44, 'CATALOG_NUMBER' => 45, 'ORIGINAL_ARTIST' => 46, 'COPYRIGHT' => 47, 'REPORT_DATETIME' => 48, 'REPORT_LOCATION' => 49, 'REPORT_ORGANIZATION' => 50, 'SUBJECT' => 51, 'CONTRIBUTOR' => 52, 'LANGUAGE' => 53, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'gunid' => 1, 'name' => 2, 'mime' => 3, 'ftype' => 4, 'filepath' => 5, 'state' => 6, 'currentlyaccessing' => 7, 'editedby' => 8, 'mtime' => 9, 'md5' => 10, 'track_title' => 11, 'artist_name' => 12, 'bit_rate' => 13, 'sample_rate' => 14, 'format' => 15, 'length' => 16, 'album_title' => 17, 'genre' => 18, 'comments' => 19, 'year' => 20, 'track_number' => 21, 'channels' => 22, 'url' => 23, 'bpm' => 24, 'rating' => 25, 'encoded_by' => 26, 'disc_number' => 27, 'mood' => 28, 'label' => 29, 'composer' => 30, 'encoder' => 31, 'checksum' => 32, 'lyrics' => 33, 'orchestra' => 34, 'conductor' => 35, 'lyricist' => 36, 'original_lyricist' => 37, 'radio_station_name' => 38, 'info_url' => 39, 'artist_url' => 40, 'audio_source_url' => 41, 'radio_station_url' => 42, 'buy_this_url' => 43, 'isrc_number' => 44, 'catalog_number' => 45, 'original_artist' => 46, 'copyright' => 47, 'report_datetime' => 48, 'report_location' => 49, 'report_organization' => 50, 'subject' => 51, 'contributor' => 52, 'language' => 53, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, ) + ); + + /** + * 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. CcFilesPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcFilesPeer::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(CcFilesPeer::ID); + $criteria->addSelectColumn(CcFilesPeer::GUNID); + $criteria->addSelectColumn(CcFilesPeer::NAME); + $criteria->addSelectColumn(CcFilesPeer::MIME); + $criteria->addSelectColumn(CcFilesPeer::FTYPE); + $criteria->addSelectColumn(CcFilesPeer::FILEPATH); + $criteria->addSelectColumn(CcFilesPeer::STATE); + $criteria->addSelectColumn(CcFilesPeer::CURRENTLYACCESSING); + $criteria->addSelectColumn(CcFilesPeer::EDITEDBY); + $criteria->addSelectColumn(CcFilesPeer::MTIME); + $criteria->addSelectColumn(CcFilesPeer::MD5); + $criteria->addSelectColumn(CcFilesPeer::TRACK_TITLE); + $criteria->addSelectColumn(CcFilesPeer::ARTIST_NAME); + $criteria->addSelectColumn(CcFilesPeer::BIT_RATE); + $criteria->addSelectColumn(CcFilesPeer::SAMPLE_RATE); + $criteria->addSelectColumn(CcFilesPeer::FORMAT); + $criteria->addSelectColumn(CcFilesPeer::LENGTH); + $criteria->addSelectColumn(CcFilesPeer::ALBUM_TITLE); + $criteria->addSelectColumn(CcFilesPeer::GENRE); + $criteria->addSelectColumn(CcFilesPeer::COMMENTS); + $criteria->addSelectColumn(CcFilesPeer::YEAR); + $criteria->addSelectColumn(CcFilesPeer::TRACK_NUMBER); + $criteria->addSelectColumn(CcFilesPeer::CHANNELS); + $criteria->addSelectColumn(CcFilesPeer::URL); + $criteria->addSelectColumn(CcFilesPeer::BPM); + $criteria->addSelectColumn(CcFilesPeer::RATING); + $criteria->addSelectColumn(CcFilesPeer::ENCODED_BY); + $criteria->addSelectColumn(CcFilesPeer::DISC_NUMBER); + $criteria->addSelectColumn(CcFilesPeer::MOOD); + $criteria->addSelectColumn(CcFilesPeer::LABEL); + $criteria->addSelectColumn(CcFilesPeer::COMPOSER); + $criteria->addSelectColumn(CcFilesPeer::ENCODER); + $criteria->addSelectColumn(CcFilesPeer::CHECKSUM); + $criteria->addSelectColumn(CcFilesPeer::LYRICS); + $criteria->addSelectColumn(CcFilesPeer::ORCHESTRA); + $criteria->addSelectColumn(CcFilesPeer::CONDUCTOR); + $criteria->addSelectColumn(CcFilesPeer::LYRICIST); + $criteria->addSelectColumn(CcFilesPeer::ORIGINAL_LYRICIST); + $criteria->addSelectColumn(CcFilesPeer::RADIO_STATION_NAME); + $criteria->addSelectColumn(CcFilesPeer::INFO_URL); + $criteria->addSelectColumn(CcFilesPeer::ARTIST_URL); + $criteria->addSelectColumn(CcFilesPeer::AUDIO_SOURCE_URL); + $criteria->addSelectColumn(CcFilesPeer::RADIO_STATION_URL); + $criteria->addSelectColumn(CcFilesPeer::BUY_THIS_URL); + $criteria->addSelectColumn(CcFilesPeer::ISRC_NUMBER); + $criteria->addSelectColumn(CcFilesPeer::CATALOG_NUMBER); + $criteria->addSelectColumn(CcFilesPeer::ORIGINAL_ARTIST); + $criteria->addSelectColumn(CcFilesPeer::COPYRIGHT); + $criteria->addSelectColumn(CcFilesPeer::REPORT_DATETIME); + $criteria->addSelectColumn(CcFilesPeer::REPORT_LOCATION); + $criteria->addSelectColumn(CcFilesPeer::REPORT_ORGANIZATION); + $criteria->addSelectColumn(CcFilesPeer::SUBJECT); + $criteria->addSelectColumn(CcFilesPeer::CONTRIBUTOR); + $criteria->addSelectColumn(CcFilesPeer::LANGUAGE); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.GUNID'); + $criteria->addSelectColumn($alias . '.NAME'); + $criteria->addSelectColumn($alias . '.MIME'); + $criteria->addSelectColumn($alias . '.FTYPE'); + $criteria->addSelectColumn($alias . '.FILEPATH'); + $criteria->addSelectColumn($alias . '.STATE'); + $criteria->addSelectColumn($alias . '.CURRENTLYACCESSING'); + $criteria->addSelectColumn($alias . '.EDITEDBY'); + $criteria->addSelectColumn($alias . '.MTIME'); + $criteria->addSelectColumn($alias . '.MD5'); + $criteria->addSelectColumn($alias . '.TRACK_TITLE'); + $criteria->addSelectColumn($alias . '.ARTIST_NAME'); + $criteria->addSelectColumn($alias . '.BIT_RATE'); + $criteria->addSelectColumn($alias . '.SAMPLE_RATE'); + $criteria->addSelectColumn($alias . '.FORMAT'); + $criteria->addSelectColumn($alias . '.LENGTH'); + $criteria->addSelectColumn($alias . '.ALBUM_TITLE'); + $criteria->addSelectColumn($alias . '.GENRE'); + $criteria->addSelectColumn($alias . '.COMMENTS'); + $criteria->addSelectColumn($alias . '.YEAR'); + $criteria->addSelectColumn($alias . '.TRACK_NUMBER'); + $criteria->addSelectColumn($alias . '.CHANNELS'); + $criteria->addSelectColumn($alias . '.URL'); + $criteria->addSelectColumn($alias . '.BPM'); + $criteria->addSelectColumn($alias . '.RATING'); + $criteria->addSelectColumn($alias . '.ENCODED_BY'); + $criteria->addSelectColumn($alias . '.DISC_NUMBER'); + $criteria->addSelectColumn($alias . '.MOOD'); + $criteria->addSelectColumn($alias . '.LABEL'); + $criteria->addSelectColumn($alias . '.COMPOSER'); + $criteria->addSelectColumn($alias . '.ENCODER'); + $criteria->addSelectColumn($alias . '.CHECKSUM'); + $criteria->addSelectColumn($alias . '.LYRICS'); + $criteria->addSelectColumn($alias . '.ORCHESTRA'); + $criteria->addSelectColumn($alias . '.CONDUCTOR'); + $criteria->addSelectColumn($alias . '.LYRICIST'); + $criteria->addSelectColumn($alias . '.ORIGINAL_LYRICIST'); + $criteria->addSelectColumn($alias . '.RADIO_STATION_NAME'); + $criteria->addSelectColumn($alias . '.INFO_URL'); + $criteria->addSelectColumn($alias . '.ARTIST_URL'); + $criteria->addSelectColumn($alias . '.AUDIO_SOURCE_URL'); + $criteria->addSelectColumn($alias . '.RADIO_STATION_URL'); + $criteria->addSelectColumn($alias . '.BUY_THIS_URL'); + $criteria->addSelectColumn($alias . '.ISRC_NUMBER'); + $criteria->addSelectColumn($alias . '.CATALOG_NUMBER'); + $criteria->addSelectColumn($alias . '.ORIGINAL_ARTIST'); + $criteria->addSelectColumn($alias . '.COPYRIGHT'); + $criteria->addSelectColumn($alias . '.REPORT_DATETIME'); + $criteria->addSelectColumn($alias . '.REPORT_LOCATION'); + $criteria->addSelectColumn($alias . '.REPORT_ORGANIZATION'); + $criteria->addSelectColumn($alias . '.SUBJECT'); + $criteria->addSelectColumn($alias . '.CONTRIBUTOR'); + $criteria->addSelectColumn($alias . '.LANGUAGE'); + } + } + + /** + * 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(CcFilesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcFilesPeer::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(CcFilesPeer::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 CcFiles + * @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 = CcFilesPeer::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 CcFilesPeer::populateObjects(CcFilesPeer::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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcFilesPeer::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 CcFiles $value A CcFiles object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcFiles $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 CcFiles object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcFiles) { + $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 CcFiles 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 CcFiles 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_files + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcPlaylistcontentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlaylistcontentsPeer::clearInstancePool(); + } + + /** + * 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 = CcFilesPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcFilesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcFilesPeer::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; + CcFilesPeer::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 (CcFiles object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcFilesPeer::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 + CcFilesPeer::NUM_COLUMNS; + } else { + $cls = CcFilesPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcFilesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcFilesPeer::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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::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 CcFiles objects pre-filled with their CcSubjs 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 CcFiles objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol = (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcFilesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcFilesPeer::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 = CcFilesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcFilesPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcFiles) to $obj2 (CcSubjs) + $obj2->addCcFiles($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(CcFilesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcFilesPeer::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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::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 CcFiles 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 CcFiles 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); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol2 = (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcFilesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcFilesPeer::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 = CcFilesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcFilesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcFiles) to the collection in $obj2 (CcSubjs) + $obj2->addCcFiles($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(BaseCcFilesPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcFilesPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcFilesTableMap()); + } + } + + /** + * 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 ? CcFilesPeer::CLASS_DEFAULT : CcFilesPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcFiles or Criteria object. + * + * @param mixed $values Criteria or CcFiles 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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcFiles object + } + + if ($criteria->containsKey(CcFilesPeer::ID) && $criteria->keyContainsValue(CcFilesPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcFilesPeer::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 CcFiles or Criteria object. + * + * @param mixed $values Criteria or CcFiles 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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcFilesPeer::ID); + $value = $criteria->remove(CcFilesPeer::ID); + if ($value) { + $selectCriteria->add(CcFilesPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcFilesPeer::TABLE_NAME); + } + + } else { // $values is CcFiles 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_files 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(CcFilesPeer::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(CcFilesPeer::TABLE_NAME, $con, CcFilesPeer::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). + CcFilesPeer::clearInstancePool(); + CcFilesPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcFiles or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcFiles 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(CcFilesPeer::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. + CcFilesPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcFiles) { // it's a model object + // invalidate the cache for this single object + CcFilesPeer::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(CcFilesPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcFilesPeer::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); + CcFilesPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcFiles 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 CcFiles $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(CcFiles $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcFilesPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcFilesPeer::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(CcFilesPeer::DATABASE_NAME, CcFilesPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcFiles + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcFilesPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcFilesPeer::DATABASE_NAME); + $criteria->add(CcFilesPeer::ID, $pk); + + $v = CcFilesPeer::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(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcFilesPeer::DATABASE_NAME); + $criteria->add(CcFilesPeer::ID, $pks, Criteria::IN); + $objs = CcFilesPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcFilesPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcFilesPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcFilesQuery.php b/application/models/campcaster/om/BaseCcFilesQuery.php new file mode 100644 index 000000000..03136febe --- /dev/null +++ b/application/models/campcaster/om/BaseCcFilesQuery.php @@ -0,0 +1,1733 @@ +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 CcFiles|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcFilesPeer::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 CcFilesQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcFilesPeer::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 CcFilesQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcFilesPeer::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 CcFilesQuery 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(CcFilesPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the gunid column + * + * @param string $gunid 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByGunid($gunid = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($gunid)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $gunid)) { + $gunid = str_replace('*', '%', $gunid); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::GUNID, $gunid, $comparison); + } + + /** + * Filter the query on the name column + * + * @param string $name 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByName($name = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($name)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $name)) { + $name = str_replace('*', '%', $name); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the mime column + * + * @param string $mime 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByMime($mime = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($mime)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $mime)) { + $mime = str_replace('*', '%', $mime); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::MIME, $mime, $comparison); + } + + /** + * Filter the query on the ftype column + * + * @param string $ftype 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByFtype($ftype = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($ftype)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $ftype)) { + $ftype = str_replace('*', '%', $ftype); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::FTYPE, $ftype, $comparison); + } + + /** + * Filter the query on the filepath column + * + * @param string $filepath 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByfilepath($filepath = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($filepath)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $filepath)) { + $filepath = str_replace('*', '%', $filepath); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::FILEPATH, $filepath, $comparison); + } + + /** + * Filter the query on the state column + * + * @param string $state 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByState($state = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($state)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $state)) { + $state = str_replace('*', '%', $state); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::STATE, $state, $comparison); + } + + /** + * Filter the query on the currentlyaccessing column + * + * @param int|array $currentlyaccessing The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByCurrentlyaccessing($currentlyaccessing = null, $comparison = null) + { + if (is_array($currentlyaccessing)) { + $useMinMax = false; + if (isset($currentlyaccessing['min'])) { + $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $currentlyaccessing['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($currentlyaccessing['max'])) { + $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $currentlyaccessing['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $currentlyaccessing, $comparison); + } + + /** + * Filter the query on the editedby column + * + * @param int|array $editedby The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByEditedby($editedby = null, $comparison = null) + { + if (is_array($editedby)) { + $useMinMax = false; + if (isset($editedby['min'])) { + $this->addUsingAlias(CcFilesPeer::EDITEDBY, $editedby['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($editedby['max'])) { + $this->addUsingAlias(CcFilesPeer::EDITEDBY, $editedby['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::EDITEDBY, $editedby, $comparison); + } + + /** + * Filter the query on the mtime column + * + * @param string|array $mtime The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByMtime($mtime = null, $comparison = null) + { + if (is_array($mtime)) { + $useMinMax = false; + if (isset($mtime['min'])) { + $this->addUsingAlias(CcFilesPeer::MTIME, $mtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($mtime['max'])) { + $this->addUsingAlias(CcFilesPeer::MTIME, $mtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::MTIME, $mtime, $comparison); + } + + /** + * Filter the query on the md5 column + * + * @param string $md5 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByMd5($md5 = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($md5)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $md5)) { + $md5 = str_replace('*', '%', $md5); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::MD5, $md5, $comparison); + } + + /** + * Filter the query on the track_title column + * + * @param string $trackTitle 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByTrackTitle($trackTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($trackTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $trackTitle)) { + $trackTitle = str_replace('*', '%', $trackTitle); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::TRACK_TITLE, $trackTitle, $comparison); + } + + /** + * Filter the query on the artist_name column + * + * @param string $artistName 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByArtistName($artistName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($artistName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $artistName)) { + $artistName = str_replace('*', '%', $artistName); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ARTIST_NAME, $artistName, $comparison); + } + + /** + * Filter the query on the bit_rate column + * + * @param string $bitRate 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByBitRate($bitRate = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($bitRate)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $bitRate)) { + $bitRate = str_replace('*', '%', $bitRate); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::BIT_RATE, $bitRate, $comparison); + } + + /** + * Filter the query on the sample_rate column + * + * @param string $sampleRate 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 CcFilesQuery The current query, for fluid interface + */ + public function filterBySampleRate($sampleRate = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($sampleRate)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $sampleRate)) { + $sampleRate = str_replace('*', '%', $sampleRate); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $sampleRate, $comparison); + } + + /** + * Filter the query on the format column + * + * @param string $format 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByFormat($format = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($format)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $format)) { + $format = str_replace('*', '%', $format); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::FORMAT, $format, $comparison); + } + + /** + * Filter the query on the length column + * + * @param string|array $dbLength The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbLength($dbLength = null, $comparison = null) + { + if (is_array($dbLength)) { + $useMinMax = false; + if (isset($dbLength['min'])) { + $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLength['max'])) { + $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength, $comparison); + } + + /** + * Filter the query on the album_title column + * + * @param string $albumTitle 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByAlbumTitle($albumTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($albumTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $albumTitle)) { + $albumTitle = str_replace('*', '%', $albumTitle); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ALBUM_TITLE, $albumTitle, $comparison); + } + + /** + * Filter the query on the genre column + * + * @param string $genre 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByGenre($genre = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($genre)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $genre)) { + $genre = str_replace('*', '%', $genre); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::GENRE, $genre, $comparison); + } + + /** + * Filter the query on the comments column + * + * @param string $comments 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByComments($comments = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($comments)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $comments)) { + $comments = str_replace('*', '%', $comments); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::COMMENTS, $comments, $comparison); + } + + /** + * Filter the query on the year column + * + * @param string $year 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByYear($year = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($year)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $year)) { + $year = str_replace('*', '%', $year); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::YEAR, $year, $comparison); + } + + /** + * Filter the query on the track_number column + * + * @param int|array $trackNumber The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByTrackNumber($trackNumber = null, $comparison = null) + { + if (is_array($trackNumber)) { + $useMinMax = false; + if (isset($trackNumber['min'])) { + $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $trackNumber['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($trackNumber['max'])) { + $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $trackNumber['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $trackNumber, $comparison); + } + + /** + * Filter the query on the channels column + * + * @param int|array $channels The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByChannels($channels = null, $comparison = null) + { + if (is_array($channels)) { + $useMinMax = false; + if (isset($channels['min'])) { + $this->addUsingAlias(CcFilesPeer::CHANNELS, $channels['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($channels['max'])) { + $this->addUsingAlias(CcFilesPeer::CHANNELS, $channels['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::CHANNELS, $channels, $comparison); + } + + /** + * Filter the query on the url column + * + * @param string $url 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByUrl($url = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($url)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $url)) { + $url = str_replace('*', '%', $url); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::URL, $url, $comparison); + } + + /** + * Filter the query on the bpm column + * + * @param string $bpm 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByBpm($bpm = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($bpm)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $bpm)) { + $bpm = str_replace('*', '%', $bpm); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::BPM, $bpm, $comparison); + } + + /** + * Filter the query on the rating column + * + * @param string $rating 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByRating($rating = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rating)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rating)) { + $rating = str_replace('*', '%', $rating); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::RATING, $rating, $comparison); + } + + /** + * Filter the query on the encoded_by column + * + * @param string $encodedBy 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByEncodedBy($encodedBy = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($encodedBy)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $encodedBy)) { + $encodedBy = str_replace('*', '%', $encodedBy); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ENCODED_BY, $encodedBy, $comparison); + } + + /** + * Filter the query on the disc_number column + * + * @param string $discNumber 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByDiscNumber($discNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($discNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $discNumber)) { + $discNumber = str_replace('*', '%', $discNumber); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::DISC_NUMBER, $discNumber, $comparison); + } + + /** + * Filter the query on the mood column + * + * @param string $mood 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByMood($mood = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($mood)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $mood)) { + $mood = str_replace('*', '%', $mood); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::MOOD, $mood, $comparison); + } + + /** + * Filter the query on the label column + * + * @param string $label 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByLabel($label = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($label)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $label)) { + $label = str_replace('*', '%', $label); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::LABEL, $label, $comparison); + } + + /** + * Filter the query on the composer column + * + * @param string $composer 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByComposer($composer = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($composer)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $composer)) { + $composer = str_replace('*', '%', $composer); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::COMPOSER, $composer, $comparison); + } + + /** + * Filter the query on the encoder column + * + * @param string $encoder 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByEncoder($encoder = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($encoder)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $encoder)) { + $encoder = str_replace('*', '%', $encoder); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ENCODER, $encoder, $comparison); + } + + /** + * Filter the query on the checksum column + * + * @param string $checksum 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByChecksum($checksum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($checksum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $checksum)) { + $checksum = str_replace('*', '%', $checksum); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::CHECKSUM, $checksum, $comparison); + } + + /** + * Filter the query on the lyrics column + * + * @param string $lyrics 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByLyrics($lyrics = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($lyrics)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $lyrics)) { + $lyrics = str_replace('*', '%', $lyrics); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::LYRICS, $lyrics, $comparison); + } + + /** + * Filter the query on the orchestra column + * + * @param string $orchestra 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByOrchestra($orchestra = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($orchestra)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $orchestra)) { + $orchestra = str_replace('*', '%', $orchestra); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ORCHESTRA, $orchestra, $comparison); + } + + /** + * Filter the query on the conductor column + * + * @param string $conductor 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByConductor($conductor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($conductor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $conductor)) { + $conductor = str_replace('*', '%', $conductor); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::CONDUCTOR, $conductor, $comparison); + } + + /** + * Filter the query on the lyricist column + * + * @param string $lyricist 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByLyricist($lyricist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($lyricist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $lyricist)) { + $lyricist = str_replace('*', '%', $lyricist); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::LYRICIST, $lyricist, $comparison); + } + + /** + * Filter the query on the original_lyricist column + * + * @param string $originalLyricist 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByOriginalLyricist($originalLyricist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($originalLyricist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $originalLyricist)) { + $originalLyricist = str_replace('*', '%', $originalLyricist); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ORIGINAL_LYRICIST, $originalLyricist, $comparison); + } + + /** + * Filter the query on the radio_station_name column + * + * @param string $radioStationName 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByRadioStationName($radioStationName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($radioStationName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $radioStationName)) { + $radioStationName = str_replace('*', '%', $radioStationName); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_NAME, $radioStationName, $comparison); + } + + /** + * Filter the query on the info_url column + * + * @param string $infoUrl 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByInfoUrl($infoUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($infoUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $infoUrl)) { + $infoUrl = str_replace('*', '%', $infoUrl); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::INFO_URL, $infoUrl, $comparison); + } + + /** + * Filter the query on the artist_url column + * + * @param string $artistUrl 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByArtistUrl($artistUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($artistUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $artistUrl)) { + $artistUrl = str_replace('*', '%', $artistUrl); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ARTIST_URL, $artistUrl, $comparison); + } + + /** + * Filter the query on the audio_source_url column + * + * @param string $audioSourceUrl 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByAudioSourceUrl($audioSourceUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($audioSourceUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $audioSourceUrl)) { + $audioSourceUrl = str_replace('*', '%', $audioSourceUrl); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::AUDIO_SOURCE_URL, $audioSourceUrl, $comparison); + } + + /** + * Filter the query on the radio_station_url column + * + * @param string $radioStationUrl 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByRadioStationUrl($radioStationUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($radioStationUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $radioStationUrl)) { + $radioStationUrl = str_replace('*', '%', $radioStationUrl); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_URL, $radioStationUrl, $comparison); + } + + /** + * Filter the query on the buy_this_url column + * + * @param string $buyThisUrl 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByBuyThisUrl($buyThisUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($buyThisUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $buyThisUrl)) { + $buyThisUrl = str_replace('*', '%', $buyThisUrl); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::BUY_THIS_URL, $buyThisUrl, $comparison); + } + + /** + * Filter the query on the isrc_number column + * + * @param string $isrcNumber 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByIsrcNumber($isrcNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($isrcNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $isrcNumber)) { + $isrcNumber = str_replace('*', '%', $isrcNumber); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ISRC_NUMBER, $isrcNumber, $comparison); + } + + /** + * Filter the query on the catalog_number column + * + * @param string $catalogNumber 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByCatalogNumber($catalogNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($catalogNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $catalogNumber)) { + $catalogNumber = str_replace('*', '%', $catalogNumber); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::CATALOG_NUMBER, $catalogNumber, $comparison); + } + + /** + * Filter the query on the original_artist column + * + * @param string $originalArtist 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByOriginalArtist($originalArtist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($originalArtist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $originalArtist)) { + $originalArtist = str_replace('*', '%', $originalArtist); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::ORIGINAL_ARTIST, $originalArtist, $comparison); + } + + /** + * Filter the query on the copyright column + * + * @param string $copyright 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByCopyright($copyright = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($copyright)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $copyright)) { + $copyright = str_replace('*', '%', $copyright); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::COPYRIGHT, $copyright, $comparison); + } + + /** + * Filter the query on the report_datetime column + * + * @param string $reportDatetime 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByReportDatetime($reportDatetime = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($reportDatetime)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $reportDatetime)) { + $reportDatetime = str_replace('*', '%', $reportDatetime); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::REPORT_DATETIME, $reportDatetime, $comparison); + } + + /** + * Filter the query on the report_location column + * + * @param string $reportLocation 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByReportLocation($reportLocation = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($reportLocation)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $reportLocation)) { + $reportLocation = str_replace('*', '%', $reportLocation); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::REPORT_LOCATION, $reportLocation, $comparison); + } + + /** + * Filter the query on the report_organization column + * + * @param string $reportOrganization 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByReportOrganization($reportOrganization = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($reportOrganization)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $reportOrganization)) { + $reportOrganization = str_replace('*', '%', $reportOrganization); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::REPORT_ORGANIZATION, $reportOrganization, $comparison); + } + + /** + * Filter the query on the subject column + * + * @param string $subject 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 CcFilesQuery The current query, for fluid interface + */ + public function filterBySubject($subject = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($subject)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $subject)) { + $subject = str_replace('*', '%', $subject); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::SUBJECT, $subject, $comparison); + } + + /** + * Filter the query on the contributor column + * + * @param string $contributor 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByContributor($contributor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($contributor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $contributor)) { + $contributor = str_replace('*', '%', $contributor); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::CONTRIBUTOR, $contributor, $comparison); + } + + /** + * Filter the query on the language column + * + * @param string $language 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByLanguage($language = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($language)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $language)) { + $language = str_replace('*', '%', $language); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::LANGUAGE, $language, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcFilesPeer::EDITEDBY, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Filter the query by a related CcPlaylistcontents object + * + * @param CcPlaylistcontents $ccPlaylistcontents the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) + { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccPlaylistcontents->getDbFileId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcPlaylistcontents relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function joinCcPlaylistcontents($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlaylistcontents'); + + // 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, 'CcPlaylistcontents'); + } + + return $this; + } + + /** + * Use the CcPlaylistcontents relation CcPlaylistcontents 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 CcPlaylistcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistcontentsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylistcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', 'CcPlaylistcontentsQuery'); + } + + /** + * Exclude object from result + * + * @param CcFiles $ccFiles Object to remove from the list of results + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function prune($ccFiles = null) + { + if ($ccFiles) { + $this->addUsingAlias(CcFilesPeer::ID, $ccFiles->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcFilesQuery diff --git a/application/models/campcaster/om/BaseCcPerms.php b/application/models/campcaster/om/BaseCcPerms.php new file mode 100644 index 000000000..a7398920f --- /dev/null +++ b/application/models/campcaster/om/BaseCcPerms.php @@ -0,0 +1,945 @@ +permid; + } + + /** + * Get the [subj] column value. + * + * @return int + */ + public function getSubj() + { + return $this->subj; + } + + /** + * Get the [action] column value. + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * Get the [obj] column value. + * + * @return int + */ + public function getObj() + { + return $this->obj; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set the value of [permid] column. + * + * @param int $v new value + * @return CcPerms The current object (for fluent API support) + */ + public function setPermid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->permid !== $v) { + $this->permid = $v; + $this->modifiedColumns[] = CcPermsPeer::PERMID; + } + + return $this; + } // setPermid() + + /** + * Set the value of [subj] column. + * + * @param int $v new value + * @return CcPerms The current object (for fluent API support) + */ + public function setSubj($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->subj !== $v) { + $this->subj = $v; + $this->modifiedColumns[] = CcPermsPeer::SUBJ; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setSubj() + + /** + * Set the value of [action] column. + * + * @param string $v new value + * @return CcPerms The current object (for fluent API support) + */ + public function setAction($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->action !== $v) { + $this->action = $v; + $this->modifiedColumns[] = CcPermsPeer::ACTION; + } + + return $this; + } // setAction() + + /** + * Set the value of [obj] column. + * + * @param int $v new value + * @return CcPerms The current object (for fluent API support) + */ + public function setObj($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->obj !== $v) { + $this->obj = $v; + $this->modifiedColumns[] = CcPermsPeer::OBJ; + } + + return $this; + } // setObj() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcPerms The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcPermsPeer::TYPE; + } + + return $this; + } // setType() + + /** + * 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->permid = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; + $this->subj = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->obj = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->type = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcPerms 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->aCcSubjs !== null && $this->subj !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcPermsPeer::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 = CcPermsPeer::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->aCcSubjs = 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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcPermsQuery::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(CcPermsPeer::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); + CcPermsPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setNew(false); + } else { + $affectedRows += CcPermsPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcPermsPeer::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 = CcPermsPeer::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->getPermid(); + break; + case 1: + return $this->getSubj(); + break; + case 2: + return $this->getAction(); + break; + case 3: + return $this->getObj(); + break; + case 4: + return $this->getType(); + 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 = CcPermsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getPermid(), + $keys[1] => $this->getSubj(), + $keys[2] => $this->getAction(), + $keys[3] => $this->getObj(), + $keys[4] => $this->getType(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcPermsPeer::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->setPermid($value); + break; + case 1: + $this->setSubj($value); + break; + case 2: + $this->setAction($value); + break; + case 3: + $this->setObj($value); + break; + case 4: + $this->setType($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 = CcPermsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setPermid($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSubj($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setObj($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setType($arr[$keys[4]]); + } + + /** + * 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(CcPermsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPermsPeer::PERMID)) $criteria->add(CcPermsPeer::PERMID, $this->permid); + if ($this->isColumnModified(CcPermsPeer::SUBJ)) $criteria->add(CcPermsPeer::SUBJ, $this->subj); + if ($this->isColumnModified(CcPermsPeer::ACTION)) $criteria->add(CcPermsPeer::ACTION, $this->action); + if ($this->isColumnModified(CcPermsPeer::OBJ)) $criteria->add(CcPermsPeer::OBJ, $this->obj); + if ($this->isColumnModified(CcPermsPeer::TYPE)) $criteria->add(CcPermsPeer::TYPE, $this->type); + + 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(CcPermsPeer::DATABASE_NAME); + $criteria->add(CcPermsPeer::PERMID, $this->permid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getPermid(); + } + + /** + * Generic method to set the primary key (permid column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setPermid($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getPermid(); + } + + /** + * 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 CcPerms (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->setPermid($this->permid); + $copyObj->setSubj($this->subj); + $copyObj->setAction($this->action); + $copyObj->setObj($this->obj); + $copyObj->setType($this->type); + + $copyObj->setNew(true); + } + + /** + * 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 CcPerms 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 CcPermsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPermsPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcPerms The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setSubj(NULL); + } else { + $this->setSubj($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcPerms($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->subj !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->subj, $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->aCcSubjs->addCcPermss($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->permid = null; + $this->subj = null; + $this->action = null; + $this->obj = null; + $this->type = 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->aCcSubjs = 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); + } + +} // BaseCcPerms diff --git a/application/models/campcaster/om/BaseCcPermsPeer.php b/application/models/campcaster/om/BaseCcPermsPeer.php new file mode 100644 index 000000000..2bfdaeb0e --- /dev/null +++ b/application/models/campcaster/om/BaseCcPermsPeer.php @@ -0,0 +1,984 @@ + array ('Permid', 'Subj', 'Action', 'Obj', 'Type', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('permid', 'subj', 'action', 'obj', 'type', ), + BasePeer::TYPE_COLNAME => array (self::PERMID, self::SUBJ, self::ACTION, self::OBJ, self::TYPE, ), + BasePeer::TYPE_RAW_COLNAME => array ('PERMID', 'SUBJ', 'ACTION', 'OBJ', 'TYPE', ), + BasePeer::TYPE_FIELDNAME => array ('permid', 'subj', 'action', 'obj', 'type', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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 ('Permid' => 0, 'Subj' => 1, 'Action' => 2, 'Obj' => 3, 'Type' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('permid' => 0, 'subj' => 1, 'action' => 2, 'obj' => 3, 'type' => 4, ), + BasePeer::TYPE_COLNAME => array (self::PERMID => 0, self::SUBJ => 1, self::ACTION => 2, self::OBJ => 3, self::TYPE => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('PERMID' => 0, 'SUBJ' => 1, 'ACTION' => 2, 'OBJ' => 3, 'TYPE' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('permid' => 0, 'subj' => 1, 'action' => 2, 'obj' => 3, 'type' => 4, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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. CcPermsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPermsPeer::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(CcPermsPeer::PERMID); + $criteria->addSelectColumn(CcPermsPeer::SUBJ); + $criteria->addSelectColumn(CcPermsPeer::ACTION); + $criteria->addSelectColumn(CcPermsPeer::OBJ); + $criteria->addSelectColumn(CcPermsPeer::TYPE); + } else { + $criteria->addSelectColumn($alias . '.PERMID'); + $criteria->addSelectColumn($alias . '.SUBJ'); + $criteria->addSelectColumn($alias . '.ACTION'); + $criteria->addSelectColumn($alias . '.OBJ'); + $criteria->addSelectColumn($alias . '.TYPE'); + } + } + + /** + * 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(CcPermsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPermsPeer::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(CcPermsPeer::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 CcPerms + * @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 = CcPermsPeer::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 CcPermsPeer::populateObjects(CcPermsPeer::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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPermsPeer::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 CcPerms $value A CcPerms object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcPerms $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getPermid(); + } // 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 CcPerms object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPerms) { + $key = (string) $value->getPermid(); + } 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 CcPerms 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 CcPerms 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_perms + * 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 = CcPermsPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPermsPeer::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; + CcPermsPeer::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 (CcPerms object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPermsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPermsPeer::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 + CcPermsPeer::NUM_COLUMNS; + } else { + $cls = CcPermsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPermsPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcPermsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPermsPeer::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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::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 CcPerms objects pre-filled with their CcSubjs 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 CcPerms objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcPermsPeer::addSelectColumns($criteria); + $startcol = (CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPermsPeer::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 = CcPermsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPermsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPerms) to $obj2 (CcSubjs) + $obj2->addCcPerms($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(CcPermsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPermsPeer::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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::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 CcPerms 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 CcPerms 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); + } + + CcPermsPeer::addSelectColumns($criteria); + $startcol2 = (CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPermsPeer::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 = CcPermsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPermsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPerms) to the collection in $obj2 (CcSubjs) + $obj2->addCcPerms($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(BaseCcPermsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPermsPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcPermsTableMap()); + } + } + + /** + * 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 ? CcPermsPeer::CLASS_DEFAULT : CcPermsPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcPerms or Criteria object. + * + * @param mixed $values Criteria or CcPerms 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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPerms object + } + + + // 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 CcPerms or Criteria object. + * + * @param mixed $values Criteria or CcPerms 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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPermsPeer::PERMID); + $value = $criteria->remove(CcPermsPeer::PERMID); + if ($value) { + $selectCriteria->add(CcPermsPeer::PERMID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPermsPeer::TABLE_NAME); + } + + } else { // $values is CcPerms 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_perms 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(CcPermsPeer::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(CcPermsPeer::TABLE_NAME, $con, CcPermsPeer::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). + CcPermsPeer::clearInstancePool(); + CcPermsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcPerms or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPerms 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(CcPermsPeer::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. + CcPermsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPerms) { // it's a model object + // invalidate the cache for this single object + CcPermsPeer::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(CcPermsPeer::PERMID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPermsPeer::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); + CcPermsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPerms 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 CcPerms $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(CcPerms $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPermsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPermsPeer::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(CcPermsPeer::DATABASE_NAME, CcPermsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPerms + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPermsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPermsPeer::DATABASE_NAME); + $criteria->add(CcPermsPeer::PERMID, $pk); + + $v = CcPermsPeer::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(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPermsPeer::DATABASE_NAME); + $criteria->add(CcPermsPeer::PERMID, $pks, Criteria::IN); + $objs = CcPermsPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcPermsPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcPermsPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcPermsQuery.php b/application/models/campcaster/om/BaseCcPermsQuery.php new file mode 100644 index 000000000..f78dfb99e --- /dev/null +++ b/application/models/campcaster/om/BaseCcPermsQuery.php @@ -0,0 +1,355 @@ +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 CcPerms|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcPermsPeer::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 CcPermsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcPermsPeer::PERMID, $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 CcPermsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcPermsPeer::PERMID, $keys, Criteria::IN); + } + + /** + * Filter the query on the permid column + * + * @param int|array $permid 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 CcPermsQuery The current query, for fluid interface + */ + public function filterByPermid($permid = null, $comparison = null) + { + if (is_array($permid) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcPermsPeer::PERMID, $permid, $comparison); + } + + /** + * Filter the query on the subj column + * + * @param int|array $subj 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 CcPermsQuery The current query, for fluid interface + */ + public function filterBySubj($subj = null, $comparison = null) + { + if (is_array($subj)) { + $useMinMax = false; + if (isset($subj['min'])) { + $this->addUsingAlias(CcPermsPeer::SUBJ, $subj['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($subj['max'])) { + $this->addUsingAlias(CcPermsPeer::SUBJ, $subj['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPermsPeer::SUBJ, $subj, $comparison); + } + + /** + * Filter the query on the action column + * + * @param string $action 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 CcPermsQuery The current query, for fluid interface + */ + public function filterByAction($action = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($action)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $action)) { + $action = str_replace('*', '%', $action); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPermsPeer::ACTION, $action, $comparison); + } + + /** + * Filter the query on the obj column + * + * @param int|array $obj 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 CcPermsQuery The current query, for fluid interface + */ + public function filterByObj($obj = null, $comparison = null) + { + if (is_array($obj)) { + $useMinMax = false; + if (isset($obj['min'])) { + $this->addUsingAlias(CcPermsPeer::OBJ, $obj['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($obj['max'])) { + $this->addUsingAlias(CcPermsPeer::OBJ, $obj['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPermsPeer::OBJ, $obj, $comparison); + } + + /** + * Filter the query on the type column + * + * @param string $type 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 CcPermsQuery The current query, for fluid interface + */ + public function filterByType($type = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($type)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPermsPeer::TYPE, $type, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPermsQuery The current query, for fluid interface + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcPermsPeer::SUBJ, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPermsQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcPerms $ccPerms Object to remove from the list of results + * + * @return CcPermsQuery The current query, for fluid interface + */ + public function prune($ccPerms = null) + { + if ($ccPerms) { + $this->addUsingAlias(CcPermsPeer::PERMID, $ccPerms->getPermid(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcPermsQuery diff --git a/application/models/campcaster/om/BaseCcPlaylist.php b/application/models/campcaster/om/BaseCcPlaylist.php new file mode 100644 index 000000000..295060730 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylist.php @@ -0,0 +1,1365 @@ +name = ''; + $this->state = 'empty'; + $this->currentlyaccessing = 0; + } + + /** + * Initializes internal state of BaseCcPlaylist object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + return $this->id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getDbName() + { + return $this->name; + } + + /** + * Get the [state] column value. + * + * @return string + */ + public function getDbState() + { + return $this->state; + } + + /** + * Get the [currentlyaccessing] column value. + * + * @return int + */ + public function getDbCurrentlyaccessing() + { + return $this->currentlyaccessing; + } + + /** + * Get the [editedby] column value. + * + * @return int + */ + public function getDbEditedby() + { + return $this->editedby; + } + + /** + * Get the [optionally formatted] temporal [mtime] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbMtime($format = 'Y-m-d H:i:s') + { + if ($this->mtime === null) { + return null; + } + + + + try { + $dt = new DateTime($this->mtime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [creator] column value. + * + * @return string + */ + public function getDbCreator() + { + return $this->creator; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDbDescription() + { + return $this->description; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlaylist 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[] = CcPlaylistPeer::ID; + } + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v || $this->isNew()) { + $this->name = $v; + $this->modifiedColumns[] = CcPlaylistPeer::NAME; + } + + return $this; + } // setDbName() + + /** + * Set the value of [state] column. + * + * @param string $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbState($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->state !== $v || $this->isNew()) { + $this->state = $v; + $this->modifiedColumns[] = CcPlaylistPeer::STATE; + } + + return $this; + } // setDbState() + + /** + * Set the value of [currentlyaccessing] column. + * + * @param int $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbCurrentlyaccessing($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->currentlyaccessing !== $v || $this->isNew()) { + $this->currentlyaccessing = $v; + $this->modifiedColumns[] = CcPlaylistPeer::CURRENTLYACCESSING; + } + + return $this; + } // setDbCurrentlyaccessing() + + /** + * Set the value of [editedby] column. + * + * @param int $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbEditedby($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->editedby !== $v) { + $this->editedby = $v; + $this->modifiedColumns[] = CcPlaylistPeer::EDITEDBY; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setDbEditedby() + + /** + * Sets the value of [mtime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbMtime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->mtime !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->mtime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcPlaylistPeer::MTIME; + } + } // if either are not null + + return $this; + } // setDbMtime() + + /** + * Set the value of [creator] column. + * + * @param string $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbCreator($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->creator !== $v) { + $this->creator = $v; + $this->modifiedColumns[] = CcPlaylistPeer::CREATOR; + } + + return $this; + } // setDbCreator() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcPlaylistPeer::DESCRIPTION; + } + + return $this; + } // setDbDescription() + + /** + * 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() + { + if ($this->name !== '') { + return false; + } + + if ($this->state !== 'empty') { + return false; + } + + if ($this->currentlyaccessing !== 0) { + return false; + } + + // 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->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->state = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->currentlyaccessing = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->editedby = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->mtime = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->creator = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->description = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlaylist 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->aCcSubjs !== null && $this->editedby !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcPlaylistPeer::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 = CcPlaylistPeer::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->aCcSubjs = null; + $this->collCcPlaylistcontentss = 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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcPlaylistQuery::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(CcPlaylistPeer::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); + CcPlaylistPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcPlaylistPeer::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(CcPlaylistPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcPlaylistPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcPlaylistPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $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 = CcPlaylistPeer::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->getDbName(); + break; + case 2: + return $this->getDbState(); + break; + case 3: + return $this->getDbCurrentlyaccessing(); + break; + case 4: + return $this->getDbEditedby(); + break; + case 5: + return $this->getDbMtime(); + break; + case 6: + return $this->getDbCreator(); + break; + case 7: + return $this->getDbDescription(); + 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 = CcPlaylistPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbState(), + $keys[3] => $this->getDbCurrentlyaccessing(), + $keys[4] => $this->getDbEditedby(), + $keys[5] => $this->getDbMtime(), + $keys[6] => $this->getDbCreator(), + $keys[7] => $this->getDbDescription(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcPlaylistPeer::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->setDbName($value); + break; + case 2: + $this->setDbState($value); + break; + case 3: + $this->setDbCurrentlyaccessing($value); + break; + case 4: + $this->setDbEditedby($value); + break; + case 5: + $this->setDbMtime($value); + break; + case 6: + $this->setDbCreator($value); + break; + case 7: + $this->setDbDescription($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 = CcPlaylistPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbState($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbCurrentlyaccessing($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbEditedby($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbMtime($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbCreator($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbDescription($arr[$keys[7]]); + } + + /** + * 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(CcPlaylistPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlaylistPeer::ID)) $criteria->add(CcPlaylistPeer::ID, $this->id); + if ($this->isColumnModified(CcPlaylistPeer::NAME)) $criteria->add(CcPlaylistPeer::NAME, $this->name); + if ($this->isColumnModified(CcPlaylistPeer::STATE)) $criteria->add(CcPlaylistPeer::STATE, $this->state); + if ($this->isColumnModified(CcPlaylistPeer::CURRENTLYACCESSING)) $criteria->add(CcPlaylistPeer::CURRENTLYACCESSING, $this->currentlyaccessing); + if ($this->isColumnModified(CcPlaylistPeer::EDITEDBY)) $criteria->add(CcPlaylistPeer::EDITEDBY, $this->editedby); + if ($this->isColumnModified(CcPlaylistPeer::MTIME)) $criteria->add(CcPlaylistPeer::MTIME, $this->mtime); + if ($this->isColumnModified(CcPlaylistPeer::CREATOR)) $criteria->add(CcPlaylistPeer::CREATOR, $this->creator); + if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description); + + 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(CcPlaylistPeer::DATABASE_NAME); + $criteria->add(CcPlaylistPeer::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 CcPlaylist (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->setDbName($this->name); + $copyObj->setDbState($this->state); + $copyObj->setDbCurrentlyaccessing($this->currentlyaccessing); + $copyObj->setDbEditedby($this->editedby); + $copyObj->setDbMtime($this->mtime); + $copyObj->setDbCreator($this->creator); + $copyObj->setDbDescription($this->description); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCcPlaylistcontentss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlaylistcontents($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + + $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 CcPlaylist 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 CcPlaylistPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlaylistPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcPlaylist The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbEditedby(NULL); + } else { + $this->setDbEditedby($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcPlaylist($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->editedby !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->editedby, $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->aCcSubjs->addCcPlaylists($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears out the collCcPlaylistcontentss 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 addCcPlaylistcontentss() + */ + public function clearCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcPlaylistcontentss collection. + * + * By default this just sets the collCcPlaylistcontentss collection to an empty array (like clearcollCcPlaylistcontentss()); + * 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 initCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = new PropelObjectCollection(); + $this->collCcPlaylistcontentss->setModel('CcPlaylistcontents'); + } + + /** + * Gets an array of CcPlaylistcontents 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 CcPlaylistcontents[] List of CcPlaylistcontents objects + * @throws PropelException + */ + public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcPlaylistcontentss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + // return empty collection + $this->initCcPlaylistcontentss(); + } else { + $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria) + ->filterByCcPlaylist($this) + ->find($con); + if (null !== $criteria) { + return $collCcPlaylistcontentss; + } + $this->collCcPlaylistcontentss = $collCcPlaylistcontentss; + } + } + return $this->collCcPlaylistcontentss; + } + + /** + * Returns the number of related CcPlaylistcontents objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlaylistcontents objects. + * @throws PropelException + */ + public function countCcPlaylistcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcPlaylistcontentss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + return 0; + } else { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcPlaylist($this) + ->count($con); + } + } else { + return count($this->collCcPlaylistcontentss); + } + } + + /** + * Method called to associate a CcPlaylistcontents object to this object + * through the CcPlaylistcontents foreign key attribute. + * + * @param CcPlaylistcontents $l CcPlaylistcontents + * @return void + * @throws PropelException + */ + public function addCcPlaylistcontents(CcPlaylistcontents $l) + { + if ($this->collCcPlaylistcontentss === null) { + $this->initCcPlaylistcontentss(); + } + if (!$this->collCcPlaylistcontentss->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcPlaylistcontentss[]= $l; + $l->setCcPlaylist($this); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcPlaylist is new, it will return + * an empty collection; or if this CcPlaylist has previously + * been saved, it will retrieve related CcPlaylistcontentss from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcPlaylist. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects + */ + public function getCcPlaylistcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcPlaylistcontentss($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->state = null; + $this->currentlyaccessing = null; + $this->editedby = null; + $this->mtime = null; + $this->creator = null; + $this->description = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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 ($this->collCcPlaylistcontentss) { + foreach ((array) $this->collCcPlaylistcontentss as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + $this->collCcPlaylistcontentss = null; + $this->aCcSubjs = 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); + } + +} // BaseCcPlaylist diff --git a/application/models/campcaster/om/BaseCcPlaylistPeer.php b/application/models/campcaster/om/BaseCcPlaylistPeer.php new file mode 100644 index 000000000..04ff4a612 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylistPeer.php @@ -0,0 +1,1006 @@ + array ('DbId', 'DbName', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbCreator', 'DbDescription', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbCreator', 'dbDescription', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::CREATOR, self::DESCRIPTION, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'CREATOR', 'DESCRIPTION', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'creator', 'description', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * 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, 'DbName' => 1, 'DbState' => 2, 'DbCurrentlyaccessing' => 3, 'DbEditedby' => 4, 'DbMtime' => 5, 'DbCreator' => 6, 'DbDescription' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbState' => 2, 'dbCurrentlyaccessing' => 3, 'dbEditedby' => 4, 'dbMtime' => 5, 'dbCreator' => 6, 'dbDescription' => 7, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::STATE => 2, self::CURRENTLYACCESSING => 3, self::EDITEDBY => 4, self::MTIME => 5, self::CREATOR => 6, self::DESCRIPTION => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'STATE' => 2, 'CURRENTLYACCESSING' => 3, 'EDITEDBY' => 4, 'MTIME' => 5, 'CREATOR' => 6, 'DESCRIPTION' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'state' => 2, 'currentlyaccessing' => 3, 'editedby' => 4, 'mtime' => 5, 'creator' => 6, 'description' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * 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. CcPlaylistPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlaylistPeer::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(CcPlaylistPeer::ID); + $criteria->addSelectColumn(CcPlaylistPeer::NAME); + $criteria->addSelectColumn(CcPlaylistPeer::STATE); + $criteria->addSelectColumn(CcPlaylistPeer::CURRENTLYACCESSING); + $criteria->addSelectColumn(CcPlaylistPeer::EDITEDBY); + $criteria->addSelectColumn(CcPlaylistPeer::MTIME); + $criteria->addSelectColumn(CcPlaylistPeer::CREATOR); + $criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.NAME'); + $criteria->addSelectColumn($alias . '.STATE'); + $criteria->addSelectColumn($alias . '.CURRENTLYACCESSING'); + $criteria->addSelectColumn($alias . '.EDITEDBY'); + $criteria->addSelectColumn($alias . '.MTIME'); + $criteria->addSelectColumn($alias . '.CREATOR'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + } + } + + /** + * 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(CcPlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistPeer::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(CcPlaylistPeer::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 CcPlaylist + * @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 = CcPlaylistPeer::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 CcPlaylistPeer::populateObjects(CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlaylistPeer::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 CcPlaylist $value A CcPlaylist object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcPlaylist $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 CcPlaylist object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlaylist) { + $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 CcPlaylist 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 CcPlaylist 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_playlist + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcPlaylistcontentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlaylistcontentsPeer::clearInstancePool(); + } + + /** + * 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 = CcPlaylistPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlaylistPeer::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; + CcPlaylistPeer::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 (CcPlaylist object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlaylistPeer::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 + CcPlaylistPeer::NUM_COLUMNS; + } else { + $cls = CcPlaylistPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlaylistPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcPlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::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 CcPlaylist objects pre-filled with their CcSubjs 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 CcPlaylist objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol = (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistPeer::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 = CcPlaylistPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlaylist) to $obj2 (CcSubjs) + $obj2->addCcPlaylist($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(CcPlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::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 CcPlaylist 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 CcPlaylist 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); + } + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol2 = (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPlaylistPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistPeer::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 = CcPlaylistPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPlaylist) to the collection in $obj2 (CcSubjs) + $obj2->addCcPlaylist($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(BaseCcPlaylistPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlaylistPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcPlaylistTableMap()); + } + } + + /** + * 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 ? CcPlaylistPeer::CLASS_DEFAULT : CcPlaylistPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcPlaylist or Criteria object. + * + * @param mixed $values Criteria or CcPlaylist 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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlaylist object + } + + if ($criteria->containsKey(CcPlaylistPeer::ID) && $criteria->keyContainsValue(CcPlaylistPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistPeer::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 CcPlaylist or Criteria object. + * + * @param mixed $values Criteria or CcPlaylist 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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlaylistPeer::ID); + $value = $criteria->remove(CcPlaylistPeer::ID); + if ($value) { + $selectCriteria->add(CcPlaylistPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlaylistPeer::TABLE_NAME); + } + + } else { // $values is CcPlaylist 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_playlist 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(CcPlaylistPeer::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(CcPlaylistPeer::TABLE_NAME, $con, CcPlaylistPeer::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). + CcPlaylistPeer::clearInstancePool(); + CcPlaylistPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcPlaylist or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlaylist 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(CcPlaylistPeer::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. + CcPlaylistPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlaylist) { // it's a model object + // invalidate the cache for this single object + CcPlaylistPeer::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(CcPlaylistPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlaylistPeer::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); + CcPlaylistPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlaylist 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 CcPlaylist $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(CcPlaylist $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlaylistPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME, CcPlaylistPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlaylist + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlaylistPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlaylistPeer::DATABASE_NAME); + $criteria->add(CcPlaylistPeer::ID, $pk); + + $v = CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlaylistPeer::DATABASE_NAME); + $criteria->add(CcPlaylistPeer::ID, $pks, Criteria::IN); + $objs = CcPlaylistPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcPlaylistPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcPlaylistPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcPlaylistQuery.php b/application/models/campcaster/om/BaseCcPlaylistQuery.php new file mode 100644 index 000000000..237be4312 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylistQuery.php @@ -0,0 +1,510 @@ +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 CcPlaylist|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcPlaylistPeer::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 CcPlaylistQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcPlaylistPeer::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 CcPlaylistQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcPlaylistPeer::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 CcPlaylistQuery 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(CcPlaylistPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the name column + * + * @param string $dbName 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 filterByDbName($dbName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbName)) { + $dbName = str_replace('*', '%', $dbName); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPlaylistPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the state column + * + * @param string $dbState 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 filterByDbState($dbState = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbState)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbState)) { + $dbState = str_replace('*', '%', $dbState); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPlaylistPeer::STATE, $dbState, $comparison); + } + + /** + * Filter the query on the currentlyaccessing column + * + * @param int|array $dbCurrentlyaccessing 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 CcPlaylistQuery The current query, for fluid interface + */ + public function filterByDbCurrentlyaccessing($dbCurrentlyaccessing = null, $comparison = null) + { + if (is_array($dbCurrentlyaccessing)) { + $useMinMax = false; + if (isset($dbCurrentlyaccessing['min'])) { + $this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCurrentlyaccessing['max'])) { + $this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing, $comparison); + } + + /** + * Filter the query on the editedby column + * + * @param int|array $dbEditedby 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 CcPlaylistQuery The current query, for fluid interface + */ + public function filterByDbEditedby($dbEditedby = null, $comparison = null) + { + if (is_array($dbEditedby)) { + $useMinMax = false; + if (isset($dbEditedby['min'])) { + $this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEditedby['max'])) { + $this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistPeer::EDITEDBY, $dbEditedby, $comparison); + } + + /** + * Filter the query on the mtime column + * + * @param string|array $dbMtime 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 CcPlaylistQuery The current query, for fluid interface + */ + public function filterByDbMtime($dbMtime = null, $comparison = null) + { + if (is_array($dbMtime)) { + $useMinMax = false; + if (isset($dbMtime['min'])) { + $this->addUsingAlias(CcPlaylistPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbMtime['max'])) { + $this->addUsingAlias(CcPlaylistPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistPeer::MTIME, $dbMtime, $comparison); + } + + /** + * Filter the query on the creator column + * + * @param string $dbCreator 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 filterByDbCreator($dbCreator = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCreator)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCreator)) { + $dbCreator = str_replace('*', '%', $dbCreator); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPlaylistPeer::CREATOR, $dbCreator, $comparison); + } + + /** + * Filter the query on the description column + * + * @param string $dbDescription 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 filterByDbDescription($dbDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDescription)) { + $dbDescription = str_replace('*', '%', $dbDescription); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPlaylistPeer::DESCRIPTION, $dbDescription, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs 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 filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcPlaylistPeer::EDITEDBY, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs 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 joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Filter the query by a related CcPlaylistcontents object + * + * @param CcPlaylistcontents $ccPlaylistcontents 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 filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) + { + return $this + ->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylistcontents->getDbPlaylistId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcPlaylistcontents 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 joinCcPlaylistcontents($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlaylistcontents'); + + // 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, 'CcPlaylistcontents'); + } + + return $this; + } + + /** + * Use the CcPlaylistcontents relation CcPlaylistcontents 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 CcPlaylistcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistcontentsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylistcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', 'CcPlaylistcontentsQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlaylist $ccPlaylist Object to remove from the list of results + * + * @return CcPlaylistQuery The current query, for fluid interface + */ + public function prune($ccPlaylist = null) + { + if ($ccPlaylist) { + $this->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylist->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcPlaylistQuery diff --git a/application/models/campcaster/om/BaseCcPlaylistcontents.php b/application/models/campcaster/om/BaseCcPlaylistcontents.php new file mode 100644 index 000000000..53ff5fe8d --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylistcontents.php @@ -0,0 +1,1540 @@ +cliplength = '00:00:00'; + $this->cuein = '00:00:00'; + $this->cueout = '00:00:00'; + $this->fadein = '00:00:00'; + $this->fadeout = '00:00:00'; + } + + /** + * Initializes internal state of BaseCcPlaylistcontents object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + return $this->id; + } + + /** + * Get the [playlist_id] column value. + * + * @return int + */ + public function getDbPlaylistId() + { + return $this->playlist_id; + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getDbFileId() + { + return $this->file_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getDbPosition() + { + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [cliplength] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbCliplength($format = '%X') + { + if ($this->cliplength === null) { + return null; + } + + + + try { + $dt = new DateTime($this->cliplength); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cliplength, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [cuein] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbCuein($format = '%X') + { + if ($this->cuein === null) { + return null; + } + + + + try { + $dt = new DateTime($this->cuein); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cuein, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [cueout] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbCueout($format = '%X') + { + if ($this->cueout === null) { + return null; + } + + + + try { + $dt = new DateTime($this->cueout); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cueout, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [fadein] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbFadein($format = '%X') + { + if ($this->fadein === null) { + return null; + } + + + + try { + $dt = new DateTime($this->fadein); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fadein, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [fadeout] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbFadeout($format = '%X') + { + if ($this->fadeout === null) { + return null; + } + + + + try { + $dt = new DateTime($this->fadeout); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fadeout, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlaylistcontents 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[] = CcPlaylistcontentsPeer::ID; + } + + return $this; + } // setDbId() + + /** + * Set the value of [playlist_id] column. + * + * @param int $v new value + * @return CcPlaylistcontents 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[] = CcPlaylistcontentsPeer::PLAYLIST_ID; + } + + if ($this->aCcPlaylist !== null && $this->aCcPlaylist->getDbId() !== $v) { + $this->aCcPlaylist = null; + } + + return $this; + } // setDbPlaylistId() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbFileId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::FILE_ID; + } + + if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { + $this->aCcFiles = null; + } + + return $this; + } // setDbFileId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::POSITION; + } + + return $this; + } // setDbPosition() + + /** + * Sets the value of [cliplength] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCliplength($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->cliplength !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->cliplength !== null && $tmpDt = new DateTime($this->cliplength)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->cliplength = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH; + } + } // if either are not null + + return $this; + } // setDbCliplength() + + /** + * Sets the value of [cuein] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCuein($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->cuein !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->cuein !== null && $tmpDt = new DateTime($this->cuein)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->cuein = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN; + } + } // if either are not null + + return $this; + } // setDbCuein() + + /** + * Sets the value of [cueout] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCueout($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->cueout !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->cueout !== null && $tmpDt = new DateTime($this->cueout)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->cueout = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT; + } + } // if either are not null + + return $this; + } // setDbCueout() + + /** + * Sets the value of [fadein] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbFadein($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->fadein !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->fadein !== null && $tmpDt = new DateTime($this->fadein)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->fadein = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN; + } + } // if either are not null + + return $this; + } // setDbFadein() + + /** + * Sets the value of [fadeout] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbFadeout($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->fadeout !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->fadeout !== null && $tmpDt = new DateTime($this->fadeout)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->fadeout = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT; + } + } // if either are not null + + return $this; + } // setDbFadeout() + + /** + * 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() + { + if ($this->cliplength !== '00:00:00') { + return false; + } + + if ($this->cuein !== '00:00:00') { + return false; + } + + if ($this->cueout !== '00:00:00') { + return false; + } + + if ($this->fadein !== '00:00:00') { + return false; + } + + if ($this->fadeout !== '00:00:00') { + return false; + } + + // 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->playlist_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->file_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->position = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->cliplength = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->cuein = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->cueout = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->fadein = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->fadeout = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlaylistcontents 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; + } + if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { + $this->aCcFiles = 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(CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::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->aCcFiles = null; + $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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcPlaylistcontentsQuery::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(CcPlaylistcontentsPeer::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); + CcPlaylistcontentsPeer::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->aCcFiles !== null) { + if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { + $affectedRows += $this->aCcFiles->save($con); + } + $this->setCcFiles($this->aCcFiles); + } + + 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[] = CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistcontentsPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcPlaylistcontentsPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcFiles !== null) { + if (!$this->aCcFiles->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); + } + } + + if ($this->aCcPlaylist !== null) { + if (!$this->aCcPlaylist->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcPlaylist->getValidationFailures()); + } + } + + + if (($retval = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::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->getDbPlaylistId(); + break; + case 2: + return $this->getDbFileId(); + break; + case 3: + return $this->getDbPosition(); + break; + case 4: + return $this->getDbCliplength(); + break; + case 5: + return $this->getDbCuein(); + break; + case 6: + return $this->getDbCueout(); + break; + case 7: + return $this->getDbFadein(); + break; + case 8: + return $this->getDbFadeout(); + 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 = CcPlaylistcontentsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbPlaylistId(), + $keys[2] => $this->getDbFileId(), + $keys[3] => $this->getDbPosition(), + $keys[4] => $this->getDbCliplength(), + $keys[5] => $this->getDbCuein(), + $keys[6] => $this->getDbCueout(), + $keys[7] => $this->getDbFadein(), + $keys[8] => $this->getDbFadeout(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); + } + 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 = CcPlaylistcontentsPeer::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->setDbPlaylistId($value); + break; + case 2: + $this->setDbFileId($value); + break; + case 3: + $this->setDbPosition($value); + break; + case 4: + $this->setDbCliplength($value); + break; + case 5: + $this->setDbCuein($value); + break; + case 6: + $this->setDbCueout($value); + break; + case 7: + $this->setDbFadein($value); + break; + case 8: + $this->setDbFadeout($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 = CcPlaylistcontentsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbPlaylistId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbFileId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbCliplength($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbCuein($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbCueout($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbFadein($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbFadeout($arr[$keys[8]]); + } + + /** + * 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(CcPlaylistcontentsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlaylistcontentsPeer::ID)) $criteria->add(CcPlaylistcontentsPeer::ID, $this->id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::PLAYLIST_ID)) $criteria->add(CcPlaylistcontentsPeer::PLAYLIST_ID, $this->playlist_id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::FILE_ID)) $criteria->add(CcPlaylistcontentsPeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::POSITION)) $criteria->add(CcPlaylistcontentsPeer::POSITION, $this->position); + if ($this->isColumnModified(CcPlaylistcontentsPeer::CLIPLENGTH)) $criteria->add(CcPlaylistcontentsPeer::CLIPLENGTH, $this->cliplength); + if ($this->isColumnModified(CcPlaylistcontentsPeer::CUEIN)) $criteria->add(CcPlaylistcontentsPeer::CUEIN, $this->cuein); + if ($this->isColumnModified(CcPlaylistcontentsPeer::CUEOUT)) $criteria->add(CcPlaylistcontentsPeer::CUEOUT, $this->cueout); + if ($this->isColumnModified(CcPlaylistcontentsPeer::FADEIN)) $criteria->add(CcPlaylistcontentsPeer::FADEIN, $this->fadein); + if ($this->isColumnModified(CcPlaylistcontentsPeer::FADEOUT)) $criteria->add(CcPlaylistcontentsPeer::FADEOUT, $this->fadeout); + + 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(CcPlaylistcontentsPeer::DATABASE_NAME); + $criteria->add(CcPlaylistcontentsPeer::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 CcPlaylistcontents (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->setDbPlaylistId($this->playlist_id); + $copyObj->setDbFileId($this->file_id); + $copyObj->setDbPosition($this->position); + $copyObj->setDbCliplength($this->cliplength); + $copyObj->setDbCuein($this->cuein); + $copyObj->setDbCueout($this->cueout); + $copyObj->setDbFadein($this->fadein); + $copyObj->setDbFadeout($this->fadeout); + + $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 CcPlaylistcontents 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 CcPlaylistcontentsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlaylistcontentsPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcPlaylistcontents The current object (for fluent API support) + * @throws PropelException + */ + public function setCcFiles(CcFiles $v = null) + { + if ($v === null) { + $this->setDbFileId(NULL); + } else { + $this->setDbFileId($v->getDbId()); + } + + $this->aCcFiles = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcFiles object, it will not be re-added. + if ($v !== null) { + $v->addCcPlaylistcontents($this); + } + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO Optional Connection object. + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null) + { + if ($this->aCcFiles === null && ($this->file_id !== null)) { + $this->aCcFiles = CcFilesQuery::create()->findPk($this->file_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->aCcFiles->addCcPlaylistcontentss($this); + */ + } + return $this->aCcFiles; + } + + /** + * Declares an association between this object and a CcPlaylist object. + * + * @param CcPlaylist $v + * @return CcPlaylistcontents 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->addCcPlaylistcontents($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->addCcPlaylistcontentss($this); + */ + } + return $this->aCcPlaylist; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->playlist_id = null; + $this->file_id = null; + $this->position = null; + $this->cliplength = null; + $this->cuein = null; + $this->cueout = null; + $this->fadein = null; + $this->fadeout = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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->aCcFiles = null; + $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); + } + +} // BaseCcPlaylistcontents diff --git a/application/models/campcaster/om/BaseCcPlaylistcontentsPeer.php b/application/models/campcaster/om/BaseCcPlaylistcontentsPeer.php new file mode 100644 index 000000000..1d448bd34 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylistcontentsPeer.php @@ -0,0 +1,1395 @@ + array ('DbId', 'DbPlaylistId', 'DbFileId', 'DbPosition', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbFileId', 'dbPosition', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::FILE_ID, self::POSITION, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'FILE_ID', 'POSITION', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'file_id', 'position', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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, 'DbPlaylistId' => 1, 'DbFileId' => 2, 'DbPosition' => 3, 'DbCliplength' => 4, 'DbCuein' => 5, 'DbCueout' => 6, 'DbFadein' => 7, 'DbFadeout' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbFileId' => 2, 'dbPosition' => 3, 'dbCliplength' => 4, 'dbCuein' => 5, 'dbCueout' => 6, 'dbFadein' => 7, 'dbFadeout' => 8, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::FILE_ID => 2, self::POSITION => 3, self::CLIPLENGTH => 4, self::CUEIN => 5, self::CUEOUT => 6, self::FADEIN => 7, self::FADEOUT => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'FILE_ID' => 2, 'POSITION' => 3, 'CLIPLENGTH' => 4, 'CUEIN' => 5, 'CUEOUT' => 6, 'FADEIN' => 7, 'FADEOUT' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'file_id' => 2, 'position' => 3, 'cliplength' => 4, 'cuein' => 5, 'cueout' => 6, 'fadein' => 7, 'fadeout' => 8, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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. CcPlaylistcontentsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::PLAYLIST_ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::FILE_ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::POSITION); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::CLIPLENGTH); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::CUEIN); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::CUEOUT); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::FADEIN); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::FADEOUT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PLAYLIST_ID'); + $criteria->addSelectColumn($alias . '.FILE_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CLIPLENGTH'); + $criteria->addSelectColumn($alias . '.CUEIN'); + $criteria->addSelectColumn($alias . '.CUEOUT'); + $criteria->addSelectColumn($alias . '.FADEIN'); + $criteria->addSelectColumn($alias . '.FADEOUT'); + } + } + + /** + * 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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::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 CcPlaylistcontents + * @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 = CcPlaylistcontentsPeer::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 CcPlaylistcontentsPeer::populateObjects(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlaylistcontentsPeer::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 CcPlaylistcontents $value A CcPlaylistcontents object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcPlaylistcontents $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 CcPlaylistcontents object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlaylistcontents) { + $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 CcPlaylistcontents 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 CcPlaylistcontents 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_playlistcontents + * 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 = CcPlaylistcontentsPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlaylistcontentsPeer::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; + CcPlaylistcontentsPeer::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 (CcPlaylistcontents object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlaylistcontentsPeer::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 + CcPlaylistcontentsPeer::NUM_COLUMNS; + } else { + $cls = CcPlaylistcontentsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlaylistcontentsPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcFiles 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 doCountJoinCcFiles(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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::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; + } + + + /** + * 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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::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 CcPlaylistcontents objects pre-filled with their CcFiles 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 CcPlaylistcontents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcFiles(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); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol = (CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS); + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlaylistcontents) to $obj2 (CcFiles) + $obj2->addCcPlaylistcontents($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Selects a collection of CcPlaylistcontents 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 CcPlaylistcontents 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); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol = (CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS); + CcPlaylistPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlaylistcontentsPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::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 (CcPlaylistcontents) to $obj2 (CcPlaylist) + $obj2->addCcPlaylistcontents($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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlaylistcontentsPeer::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 CcPlaylistcontents 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 CcPlaylistcontents 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); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = (CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS); + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlaylistcontentsPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcFiles rows + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj2 (CcFiles) + $obj2->addCcPlaylistcontents($obj1); + } // if joined row not null + + // Add objects for joined CcPlaylist rows + + $key3 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcPlaylistPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcPlaylistPeer::getOMClass(false); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcPlaylistPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcPlaylist) + $obj3->addCcPlaylistcontents($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcFiles 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 doCountJoinAllExceptCcFiles(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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::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; + } + + + /** + * 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 doCountJoinAllExceptCcPlaylist(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(CcPlaylistcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlaylistcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::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 CcPlaylistcontents objects pre-filled with all related objects except CcFiles. + * + * @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 CcPlaylistcontents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + // $criteria->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = (CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS); + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPlaylistcontentsPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::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 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj2 (CcPlaylist) + $obj2->addCcPlaylistcontents($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Selects a collection of CcPlaylistcontents objects pre-filled with all related objects except CcPlaylist. + * + * @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 CcPlaylistcontents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcPlaylist(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + // $criteria->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = (CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS); + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlaylistcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlaylistcontentsPeer::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 = CcPlaylistcontentsPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcFiles rows + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj2 (CcFiles) + $obj2->addCcPlaylistcontents($obj1); + + } // if joined row is 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(BaseCcPlaylistcontentsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlaylistcontentsPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcPlaylistcontentsTableMap()); + } + } + + /** + * 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 ? CcPlaylistcontentsPeer::CLASS_DEFAULT : CcPlaylistcontentsPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcPlaylistcontents or Criteria object. + * + * @param mixed $values Criteria or CcPlaylistcontents 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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlaylistcontents object + } + + if ($criteria->containsKey(CcPlaylistcontentsPeer::ID) && $criteria->keyContainsValue(CcPlaylistcontentsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistcontentsPeer::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 CcPlaylistcontents or Criteria object. + * + * @param mixed $values Criteria or CcPlaylistcontents 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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlaylistcontentsPeer::ID); + $value = $criteria->remove(CcPlaylistcontentsPeer::ID); + if ($value) { + $selectCriteria->add(CcPlaylistcontentsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlaylistcontentsPeer::TABLE_NAME); + } + + } else { // $values is CcPlaylistcontents 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_playlistcontents 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(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::TABLE_NAME, $con, CcPlaylistcontentsPeer::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). + CcPlaylistcontentsPeer::clearInstancePool(); + CcPlaylistcontentsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcPlaylistcontents or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlaylistcontents 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(CcPlaylistcontentsPeer::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. + CcPlaylistcontentsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlaylistcontents) { // it's a model object + // invalidate the cache for this single object + CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlaylistcontentsPeer::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); + CcPlaylistcontentsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlaylistcontents 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 CcPlaylistcontents $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(CcPlaylistcontents $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlaylistcontentsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, CcPlaylistcontentsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlaylistcontents + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlaylistcontentsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlaylistcontentsPeer::DATABASE_NAME); + $criteria->add(CcPlaylistcontentsPeer::ID, $pk); + + $v = CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlaylistcontentsPeer::DATABASE_NAME); + $criteria->add(CcPlaylistcontentsPeer::ID, $pks, Criteria::IN); + $objs = CcPlaylistcontentsPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcPlaylistcontentsPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcPlaylistcontentsPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcPlaylistcontentsQuery.php b/application/models/campcaster/om/BaseCcPlaylistcontentsQuery.php new file mode 100644 index 000000000..183fa9a4f --- /dev/null +++ b/application/models/campcaster/om/BaseCcPlaylistcontentsQuery.php @@ -0,0 +1,581 @@ +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 CcPlaylistcontents|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcPlaylistcontentsPeer::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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcPlaylistcontentsPeer::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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcPlaylistcontentsPeer::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 CcPlaylistcontentsQuery 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(CcPlaylistcontentsPeer::ID, $dbId, $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 CcPlaylistcontentsQuery 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(CcPlaylistcontentsPeer::PLAYLIST_ID, $dbPlaylistId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPlaylistId['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $dbPlaylistId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $dbPlaylistId, $comparison); + } + + /** + * Filter the query on the file_id column + * + * @param int|array $dbFileId 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbFileId($dbFileId = null, $comparison = null) + { + if (is_array($dbFileId)) { + $useMinMax = false; + if (isset($dbFileId['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFileId['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $dbFileId, $comparison); + } + + /** + * Filter the query on the position column + * + * @param int|array $dbPosition 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbPosition($dbPosition = null, $comparison = null) + { + if (is_array($dbPosition)) { + $useMinMax = false; + if (isset($dbPosition['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPosition['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::POSITION, $dbPosition, $comparison); + } + + /** + * Filter the query on the cliplength column + * + * @param string|array $dbCliplength 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCliplength($dbCliplength = null, $comparison = null) + { + if (is_array($dbCliplength)) { + $useMinMax = false; + if (isset($dbCliplength['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CLIPLENGTH, $dbCliplength['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCliplength['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CLIPLENGTH, $dbCliplength['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::CLIPLENGTH, $dbCliplength, $comparison); + } + + /** + * Filter the query on the cuein column + * + * @param string|array $dbCuein 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCuein($dbCuein = null, $comparison = null) + { + if (is_array($dbCuein)) { + $useMinMax = false; + if (isset($dbCuein['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CUEIN, $dbCuein['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCuein['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CUEIN, $dbCuein['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEIN, $dbCuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * @param string|array $dbCueout 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCueout($dbCueout = null, $comparison = null) + { + if (is_array($dbCueout)) { + $useMinMax = false; + if (isset($dbCueout['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CUEOUT, $dbCueout['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCueout['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::CUEOUT, $dbCueout['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEOUT, $dbCueout, $comparison); + } + + /** + * Filter the query on the fadein column + * + * @param string|array $dbFadein 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbFadein($dbFadein = null, $comparison = null) + { + if (is_array($dbFadein)) { + $useMinMax = false; + if (isset($dbFadein['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FADEIN, $dbFadein['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadein['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FADEIN, $dbFadein['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::FADEIN, $dbFadein, $comparison); + } + + /** + * Filter the query on the fadeout column + * + * @param string|array $dbFadeout 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbFadeout($dbFadeout = null, $comparison = null) + { + if (is_array($dbFadeout)) { + $useMinMax = false; + if (isset($dbFadeout['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FADEOUT, $dbFadeout['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadeout['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::FADEOUT, $dbFadeout['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::FADEOUT, $dbFadeout, $comparison); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles $ccFiles the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcFiles relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcFiles'); + + // 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, 'CcFiles'); + } + + return $this; + } + + /** + * Use the CcFiles relation CcFiles 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 CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery'); + } + + /** + * 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByCcPlaylist($ccPlaylist, $comparison = null) + { + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function joinCcPlaylist($relationAlias = '', $joinType = Criteria::LEFT_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::LEFT_JOIN) + { + return $this + ->joinCcPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', 'CcPlaylistQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlaylistcontents $ccPlaylistcontents Object to remove from the list of results + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function prune($ccPlaylistcontents = null) + { + if ($ccPlaylistcontents) { + $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $ccPlaylistcontents->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcPlaylistcontentsQuery diff --git a/application/models/campcaster/om/BaseCcPref.php b/application/models/campcaster/om/BaseCcPref.php new file mode 100644 index 000000000..d1f07c596 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPref.php @@ -0,0 +1,905 @@ +id; + } + + /** + * Get the [subjid] column value. + * + * @return int + */ + public function getSubjid() + { + return $this->subjid; + } + + /** + * Get the [keystr] column value. + * + * @return string + */ + public function getKeystr() + { + return $this->keystr; + } + + /** + * Get the [valstr] column value. + * + * @return string + */ + public function getValstr() + { + return $this->valstr; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPref The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcPrefPeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [subjid] column. + * + * @param int $v new value + * @return CcPref The current object (for fluent API support) + */ + public function setSubjid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->subjid !== $v) { + $this->subjid = $v; + $this->modifiedColumns[] = CcPrefPeer::SUBJID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setSubjid() + + /** + * Set the value of [keystr] column. + * + * @param string $v new value + * @return CcPref The current object (for fluent API support) + */ + public function setKeystr($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->keystr !== $v) { + $this->keystr = $v; + $this->modifiedColumns[] = CcPrefPeer::KEYSTR; + } + + return $this; + } // setKeystr() + + /** + * Set the value of [valstr] column. + * + * @param string $v new value + * @return CcPref The current object (for fluent API support) + */ + public function setValstr($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->valstr !== $v) { + $this->valstr = $v; + $this->modifiedColumns[] = CcPrefPeer::VALSTR; + } + + return $this; + } // setValstr() + + /** + * 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->subjid = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->keystr = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->valstr = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = CcPrefPeer::NUM_COLUMNS - CcPrefPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcPref 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->aCcSubjs !== null && $this->subjid !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcPrefPeer::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 = CcPrefPeer::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->aCcSubjs = 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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcPrefQuery::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(CcPrefPeer::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); + CcPrefPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcPrefPeer::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(CcPrefPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPrefPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcPrefPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcPrefPeer::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 = CcPrefPeer::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->getId(); + break; + case 1: + return $this->getSubjid(); + break; + case 2: + return $this->getKeystr(); + break; + case 3: + return $this->getValstr(); + 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 = CcPrefPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getSubjid(), + $keys[2] => $this->getKeystr(), + $keys[3] => $this->getValstr(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcPrefPeer::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->setId($value); + break; + case 1: + $this->setSubjid($value); + break; + case 2: + $this->setKeystr($value); + break; + case 3: + $this->setValstr($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 = CcPrefPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSubjid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setKeystr($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setValstr($arr[$keys[3]]); + } + + /** + * 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(CcPrefPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPrefPeer::ID)) $criteria->add(CcPrefPeer::ID, $this->id); + if ($this->isColumnModified(CcPrefPeer::SUBJID)) $criteria->add(CcPrefPeer::SUBJID, $this->subjid); + if ($this->isColumnModified(CcPrefPeer::KEYSTR)) $criteria->add(CcPrefPeer::KEYSTR, $this->keystr); + if ($this->isColumnModified(CcPrefPeer::VALSTR)) $criteria->add(CcPrefPeer::VALSTR, $this->valstr); + + 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(CcPrefPeer::DATABASE_NAME); + $criteria->add(CcPrefPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcPref (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->setSubjid($this->subjid); + $copyObj->setKeystr($this->keystr); + $copyObj->setValstr($this->valstr); + + $copyObj->setNew(true); + $copyObj->setId(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 CcPref 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 CcPrefPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPrefPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcPref The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setSubjid(NULL); + } else { + $this->setSubjid($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcPref($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->subjid !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->subjid, $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->aCcSubjs->addCcPrefs($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->subjid = null; + $this->keystr = null; + $this->valstr = 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->aCcSubjs = 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); + } + +} // BaseCcPref diff --git a/application/models/campcaster/om/BaseCcPrefPeer.php b/application/models/campcaster/om/BaseCcPrefPeer.php new file mode 100644 index 000000000..8356fed9a --- /dev/null +++ b/application/models/campcaster/om/BaseCcPrefPeer.php @@ -0,0 +1,983 @@ + array ('Id', 'Subjid', 'Keystr', 'Valstr', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'subjid', 'keystr', 'valstr', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::SUBJID, self::KEYSTR, self::VALSTR, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SUBJID', 'KEYSTR', 'VALSTR', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'subjid', 'keystr', 'valstr', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * 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 ('Id' => 0, 'Subjid' => 1, 'Keystr' => 2, 'Valstr' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'subjid' => 1, 'keystr' => 2, 'valstr' => 3, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::SUBJID => 1, self::KEYSTR => 2, self::VALSTR => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SUBJID' => 1, 'KEYSTR' => 2, 'VALSTR' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'subjid' => 1, 'keystr' => 2, 'valstr' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * 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. CcPrefPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPrefPeer::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(CcPrefPeer::ID); + $criteria->addSelectColumn(CcPrefPeer::SUBJID); + $criteria->addSelectColumn(CcPrefPeer::KEYSTR); + $criteria->addSelectColumn(CcPrefPeer::VALSTR); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.SUBJID'); + $criteria->addSelectColumn($alias . '.KEYSTR'); + $criteria->addSelectColumn($alias . '.VALSTR'); + } + } + + /** + * 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(CcPrefPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPrefPeer::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(CcPrefPeer::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 CcPref + * @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 = CcPrefPeer::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 CcPrefPeer::populateObjects(CcPrefPeer::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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPrefPeer::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 CcPref $value A CcPref object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcPref $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcPref object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPref) { + $key = (string) $value->getId(); + } 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 CcPref 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 CcPref 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_pref + * 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 = CcPrefPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPrefPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPrefPeer::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; + CcPrefPeer::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 (CcPref object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPrefPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPrefPeer::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 + CcPrefPeer::NUM_COLUMNS; + } else { + $cls = CcPrefPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPrefPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcPrefPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPrefPeer::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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPrefPeer::SUBJID, CcSubjsPeer::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 CcPref objects pre-filled with their CcSubjs 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 CcPref objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcPrefPeer::addSelectColumns($criteria); + $startcol = (CcPrefPeer::NUM_COLUMNS - CcPrefPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPrefPeer::SUBJID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPrefPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPrefPeer::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 = CcPrefPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPrefPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPref) to $obj2 (CcSubjs) + $obj2->addCcPref($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(CcPrefPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPrefPeer::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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPrefPeer::SUBJID, CcSubjsPeer::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 CcPref 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 CcPref 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); + } + + CcPrefPeer::addSelectColumns($criteria); + $startcol2 = (CcPrefPeer::NUM_COLUMNS - CcPrefPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcPrefPeer::SUBJID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPrefPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPrefPeer::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 = CcPrefPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPrefPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPref) to the collection in $obj2 (CcSubjs) + $obj2->addCcPref($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(BaseCcPrefPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPrefPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcPrefTableMap()); + } + } + + /** + * 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 ? CcPrefPeer::CLASS_DEFAULT : CcPrefPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcPref or Criteria object. + * + * @param mixed $values Criteria or CcPref 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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPref object + } + + if ($criteria->containsKey(CcPrefPeer::ID) && $criteria->keyContainsValue(CcPrefPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPrefPeer::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 CcPref or Criteria object. + * + * @param mixed $values Criteria or CcPref 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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPrefPeer::ID); + $value = $criteria->remove(CcPrefPeer::ID); + if ($value) { + $selectCriteria->add(CcPrefPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPrefPeer::TABLE_NAME); + } + + } else { // $values is CcPref 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_pref 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(CcPrefPeer::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(CcPrefPeer::TABLE_NAME, $con, CcPrefPeer::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). + CcPrefPeer::clearInstancePool(); + CcPrefPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcPref or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPref 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(CcPrefPeer::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. + CcPrefPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPref) { // it's a model object + // invalidate the cache for this single object + CcPrefPeer::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(CcPrefPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPrefPeer::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); + CcPrefPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPref 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 CcPref $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(CcPref $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPrefPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPrefPeer::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(CcPrefPeer::DATABASE_NAME, CcPrefPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPref + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPrefPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPrefPeer::DATABASE_NAME); + $criteria->add(CcPrefPeer::ID, $pk); + + $v = CcPrefPeer::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(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPrefPeer::DATABASE_NAME); + $criteria->add(CcPrefPeer::ID, $pks, Criteria::IN); + $objs = CcPrefPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcPrefPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcPrefPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcPrefQuery.php b/application/models/campcaster/om/BaseCcPrefQuery.php new file mode 100644 index 000000000..e85c52a36 --- /dev/null +++ b/application/models/campcaster/om/BaseCcPrefQuery.php @@ -0,0 +1,320 @@ +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 CcPref|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcPrefPeer::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 CcPrefQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcPrefPeer::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 CcPrefQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcPrefPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $id 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 CcPrefQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcPrefPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the subjid column + * + * @param int|array $subjid 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 CcPrefQuery The current query, for fluid interface + */ + public function filterBySubjid($subjid = null, $comparison = null) + { + if (is_array($subjid)) { + $useMinMax = false; + if (isset($subjid['min'])) { + $this->addUsingAlias(CcPrefPeer::SUBJID, $subjid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($subjid['max'])) { + $this->addUsingAlias(CcPrefPeer::SUBJID, $subjid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPrefPeer::SUBJID, $subjid, $comparison); + } + + /** + * Filter the query on the keystr column + * + * @param string $keystr 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 CcPrefQuery The current query, for fluid interface + */ + public function filterByKeystr($keystr = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($keystr)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $keystr)) { + $keystr = str_replace('*', '%', $keystr); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPrefPeer::KEYSTR, $keystr, $comparison); + } + + /** + * Filter the query on the valstr column + * + * @param string $valstr 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 CcPrefQuery The current query, for fluid interface + */ + public function filterByValstr($valstr = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($valstr)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $valstr)) { + $valstr = str_replace('*', '%', $valstr); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcPrefPeer::VALSTR, $valstr, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPrefQuery The current query, for fluid interface + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcPrefPeer::SUBJID, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPrefQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcPref $ccPref Object to remove from the list of results + * + * @return CcPrefQuery The current query, for fluid interface + */ + public function prune($ccPref = null) + { + if ($ccPref) { + $this->addUsingAlias(CcPrefPeer::ID, $ccPref->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcPrefQuery diff --git a/application/models/campcaster/om/BaseCcSchedule.php b/application/models/campcaster/om/BaseCcSchedule.php new file mode 100644 index 000000000..39bad3761 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSchedule.php @@ -0,0 +1,1560 @@ +clip_length = '00:00:00'; + $this->fade_in = '00:00:00'; + $this->fade_out = '00:00:00'; + $this->cue_in = '00:00:00'; + $this->cue_out = '00:00:00'; + } + + /** + * Initializes internal state of BaseCcSchedule object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Get the [playlist_id] column value. + * + * @return int + */ + public function getPlaylistId() + { + return $this->playlist_id; + } + + /** + * Get the [optionally formatted] temporal [starts] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getStarts($format = 'Y-m-d H:i:s') + { + if ($this->starts === null) { + return null; + } + + + + try { + $dt = new DateTime($this->starts); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [ends] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getEnds($format = 'Y-m-d H:i:s') + { + if ($this->ends === null) { + return null; + } + + + + try { + $dt = new DateTime($this->ends); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [group_id] column value. + * + * @return int + */ + public function getGroupId() + { + return $this->group_id; + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getFileId() + { + return $this->file_id; + } + + /** + * Get the [optionally formatted] temporal [clip_length] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getClipLength($format = '%X') + { + if ($this->clip_length === null) { + return null; + } + + + + try { + $dt = new DateTime($this->clip_length); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->clip_length, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [fade_in] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getFadeIn($format = '%X') + { + if ($this->fade_in === null) { + return null; + } + + + + try { + $dt = new DateTime($this->fade_in); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fade_in, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [fade_out] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getFadeOut($format = '%X') + { + if ($this->fade_out === null) { + return null; + } + + + + try { + $dt = new DateTime($this->fade_out); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fade_out, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [cue_in] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCueIn($format = '%X') + { + if ($this->cue_in === null) { + return null; + } + + + + try { + $dt = new DateTime($this->cue_in); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cue_in, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [cue_out] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCueOut($format = '%X') + { + if ($this->cue_out === null) { + return null; + } + + + + try { + $dt = new DateTime($this->cue_out); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cue_out, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [id] column. + * + * @param string $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSchedulePeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [playlist_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setPlaylistId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->playlist_id !== $v) { + $this->playlist_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::PLAYLIST_ID; + } + + return $this; + } // setPlaylistId() + + /** + * Sets the value of [starts] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setStarts($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->starts !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->starts !== null && $tmpDt = new DateTime($this->starts)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->starts = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcSchedulePeer::STARTS; + } + } // if either are not null + + return $this; + } // setStarts() + + /** + * Sets the value of [ends] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setEnds($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->ends !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->ends !== null && $tmpDt = new DateTime($this->ends)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->ends = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcSchedulePeer::ENDS; + } + } // if either are not null + + return $this; + } // setEnds() + + /** + * Set the value of [group_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setGroupId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->group_id !== $v) { + $this->group_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::GROUP_ID; + } + + return $this; + } // setGroupId() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setFileId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::FILE_ID; + } + + return $this; + } // setFileId() + + /** + * Sets the value of [clip_length] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setClipLength($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->clip_length !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->clip_length !== null && $tmpDt = new DateTime($this->clip_length)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->clip_length = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcSchedulePeer::CLIP_LENGTH; + } + } // if either are not null + + return $this; + } // setClipLength() + + /** + * Sets the value of [fade_in] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setFadeIn($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->fade_in !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->fade_in !== null && $tmpDt = new DateTime($this->fade_in)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->fade_in = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcSchedulePeer::FADE_IN; + } + } // if either are not null + + return $this; + } // setFadeIn() + + /** + * Sets the value of [fade_out] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setFadeOut($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->fade_out !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->fade_out !== null && $tmpDt = new DateTime($this->fade_out)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->fade_out = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcSchedulePeer::FADE_OUT; + } + } // if either are not null + + return $this; + } // setFadeOut() + + /** + * Sets the value of [cue_in] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setCueIn($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->cue_in !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->cue_in !== null && $tmpDt = new DateTime($this->cue_in)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->cue_in = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcSchedulePeer::CUE_IN; + } + } // if either are not null + + return $this; + } // setCueIn() + + /** + * Sets the value of [cue_out] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSchedule The current object (for fluent API support) + */ + public function setCueOut($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->cue_out !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->cue_out !== null && $tmpDt = new DateTime($this->cue_out)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) + { + $this->cue_out = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcSchedulePeer::CUE_OUT; + } + } // if either are not null + + return $this; + } // setCueOut() + + /** + * 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() + { + if ($this->clip_length !== '00:00:00') { + return false; + } + + if ($this->fade_in !== '00:00:00') { + return false; + } + + if ($this->fade_out !== '00:00:00') { + return false; + } + + if ($this->cue_in !== '00:00:00') { + return false; + } + + if ($this->cue_out !== '00:00:00') { + return false; + } + + // 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) ? (string) $row[$startcol + 0] : null; + $this->playlist_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->starts = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->ends = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->group_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->file_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->clip_length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->fade_in = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->fade_out = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->cue_in = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->cue_out = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 11; // 11 = CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcSchedule 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() + { + + } // 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(CcSchedulePeer::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 = CcSchedulePeer::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? + + } // 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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcScheduleQuery::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(CcSchedulePeer::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); + CcSchedulePeer::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; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcSchedulePeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcSchedulePeer::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 = CcSchedulePeer::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->getId(); + break; + case 1: + return $this->getPlaylistId(); + break; + case 2: + return $this->getStarts(); + break; + case 3: + return $this->getEnds(); + break; + case 4: + return $this->getGroupId(); + break; + case 5: + return $this->getFileId(); + break; + case 6: + return $this->getClipLength(); + break; + case 7: + return $this->getFadeIn(); + break; + case 8: + return $this->getFadeOut(); + break; + case 9: + return $this->getCueIn(); + break; + case 10: + return $this->getCueOut(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcSchedulePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getPlaylistId(), + $keys[2] => $this->getStarts(), + $keys[3] => $this->getEnds(), + $keys[4] => $this->getGroupId(), + $keys[5] => $this->getFileId(), + $keys[6] => $this->getClipLength(), + $keys[7] => $this->getFadeIn(), + $keys[8] => $this->getFadeOut(), + $keys[9] => $this->getCueIn(), + $keys[10] => $this->getCueOut(), + ); + 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 = CcSchedulePeer::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->setId($value); + break; + case 1: + $this->setPlaylistId($value); + break; + case 2: + $this->setStarts($value); + break; + case 3: + $this->setEnds($value); + break; + case 4: + $this->setGroupId($value); + break; + case 5: + $this->setFileId($value); + break; + case 6: + $this->setClipLength($value); + break; + case 7: + $this->setFadeIn($value); + break; + case 8: + $this->setFadeOut($value); + break; + case 9: + $this->setCueIn($value); + break; + case 10: + $this->setCueOut($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 = CcSchedulePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setPlaylistId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setStarts($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setEnds($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setGroupId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setFileId($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setClipLength($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setFadeIn($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setFadeOut($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setCueIn($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setCueOut($arr[$keys[10]]); + } + + /** + * 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(CcSchedulePeer::DATABASE_NAME); + + if ($this->isColumnModified(CcSchedulePeer::ID)) $criteria->add(CcSchedulePeer::ID, $this->id); + if ($this->isColumnModified(CcSchedulePeer::PLAYLIST_ID)) $criteria->add(CcSchedulePeer::PLAYLIST_ID, $this->playlist_id); + if ($this->isColumnModified(CcSchedulePeer::STARTS)) $criteria->add(CcSchedulePeer::STARTS, $this->starts); + if ($this->isColumnModified(CcSchedulePeer::ENDS)) $criteria->add(CcSchedulePeer::ENDS, $this->ends); + if ($this->isColumnModified(CcSchedulePeer::GROUP_ID)) $criteria->add(CcSchedulePeer::GROUP_ID, $this->group_id); + if ($this->isColumnModified(CcSchedulePeer::FILE_ID)) $criteria->add(CcSchedulePeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcSchedulePeer::CLIP_LENGTH)) $criteria->add(CcSchedulePeer::CLIP_LENGTH, $this->clip_length); + if ($this->isColumnModified(CcSchedulePeer::FADE_IN)) $criteria->add(CcSchedulePeer::FADE_IN, $this->fade_in); + if ($this->isColumnModified(CcSchedulePeer::FADE_OUT)) $criteria->add(CcSchedulePeer::FADE_OUT, $this->fade_out); + if ($this->isColumnModified(CcSchedulePeer::CUE_IN)) $criteria->add(CcSchedulePeer::CUE_IN, $this->cue_in); + if ($this->isColumnModified(CcSchedulePeer::CUE_OUT)) $criteria->add(CcSchedulePeer::CUE_OUT, $this->cue_out); + + 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(CcSchedulePeer::DATABASE_NAME); + $criteria->add(CcSchedulePeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcSchedule (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->setId($this->id); + $copyObj->setPlaylistId($this->playlist_id); + $copyObj->setStarts($this->starts); + $copyObj->setEnds($this->ends); + $copyObj->setGroupId($this->group_id); + $copyObj->setFileId($this->file_id); + $copyObj->setClipLength($this->clip_length); + $copyObj->setFadeIn($this->fade_in); + $copyObj->setFadeOut($this->fade_out); + $copyObj->setCueIn($this->cue_in); + $copyObj->setCueOut($this->cue_out); + + $copyObj->setNew(true); + } + + /** + * 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 CcSchedule 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 CcSchedulePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcSchedulePeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->playlist_id = null; + $this->starts = null; + $this->ends = null; + $this->group_id = null; + $this->file_id = null; + $this->clip_length = null; + $this->fade_in = null; + $this->fade_out = null; + $this->cue_in = null; + $this->cue_out = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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) + + } + + /** + * 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); + } + +} // BaseCcSchedule diff --git a/application/models/campcaster/om/BaseCcSchedulePeer.php b/application/models/campcaster/om/BaseCcSchedulePeer.php new file mode 100644 index 000000000..c62a304c7 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSchedulePeer.php @@ -0,0 +1,780 @@ + array ('Id', 'PlaylistId', 'Starts', 'Ends', 'GroupId', 'FileId', 'ClipLength', 'FadeIn', 'FadeOut', 'CueIn', 'CueOut', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'playlistId', 'starts', 'ends', 'groupId', 'fileId', 'clipLength', 'fadeIn', 'fadeOut', 'cueIn', 'cueOut', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::STARTS, self::ENDS, self::GROUP_ID, self::FILE_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'STARTS', 'ENDS', 'GROUP_ID', 'FILE_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'starts', 'ends', 'group_id', 'file_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + ); + + /** + * 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 ('Id' => 0, 'PlaylistId' => 1, 'Starts' => 2, 'Ends' => 3, 'GroupId' => 4, 'FileId' => 5, 'ClipLength' => 6, 'FadeIn' => 7, 'FadeOut' => 8, 'CueIn' => 9, 'CueOut' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'playlistId' => 1, 'starts' => 2, 'ends' => 3, 'groupId' => 4, 'fileId' => 5, 'clipLength' => 6, 'fadeIn' => 7, 'fadeOut' => 8, 'cueIn' => 9, 'cueOut' => 10, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::STARTS => 2, self::ENDS => 3, self::GROUP_ID => 4, self::FILE_ID => 5, self::CLIP_LENGTH => 6, self::FADE_IN => 7, self::FADE_OUT => 8, self::CUE_IN => 9, self::CUE_OUT => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'STARTS' => 2, 'ENDS' => 3, 'GROUP_ID' => 4, 'FILE_ID' => 5, 'CLIP_LENGTH' => 6, 'FADE_IN' => 7, 'FADE_OUT' => 8, 'CUE_IN' => 9, 'CUE_OUT' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'starts' => 2, 'ends' => 3, 'group_id' => 4, 'file_id' => 5, 'clip_length' => 6, 'fade_in' => 7, 'fade_out' => 8, 'cue_in' => 9, 'cue_out' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + ); + + /** + * 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. CcSchedulePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcSchedulePeer::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(CcSchedulePeer::ID); + $criteria->addSelectColumn(CcSchedulePeer::PLAYLIST_ID); + $criteria->addSelectColumn(CcSchedulePeer::STARTS); + $criteria->addSelectColumn(CcSchedulePeer::ENDS); + $criteria->addSelectColumn(CcSchedulePeer::GROUP_ID); + $criteria->addSelectColumn(CcSchedulePeer::FILE_ID); + $criteria->addSelectColumn(CcSchedulePeer::CLIP_LENGTH); + $criteria->addSelectColumn(CcSchedulePeer::FADE_IN); + $criteria->addSelectColumn(CcSchedulePeer::FADE_OUT); + $criteria->addSelectColumn(CcSchedulePeer::CUE_IN); + $criteria->addSelectColumn(CcSchedulePeer::CUE_OUT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PLAYLIST_ID'); + $criteria->addSelectColumn($alias . '.STARTS'); + $criteria->addSelectColumn($alias . '.ENDS'); + $criteria->addSelectColumn($alias . '.GROUP_ID'); + $criteria->addSelectColumn($alias . '.FILE_ID'); + $criteria->addSelectColumn($alias . '.CLIP_LENGTH'); + $criteria->addSelectColumn($alias . '.FADE_IN'); + $criteria->addSelectColumn($alias . '.FADE_OUT'); + $criteria->addSelectColumn($alias . '.CUE_IN'); + $criteria->addSelectColumn($alias . '.CUE_OUT'); + } + } + + /** + * 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(CcSchedulePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSchedulePeer::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(CcSchedulePeer::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 CcSchedule + * @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 = CcSchedulePeer::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 CcSchedulePeer::populateObjects(CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcSchedulePeer::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 CcSchedule $value A CcSchedule object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcSchedule $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcSchedule object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSchedule) { + $key = (string) $value->getId(); + } 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 CcSchedule 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 CcSchedule 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_schedule + * 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 (string) $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 = CcSchedulePeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcSchedulePeer::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; + CcSchedulePeer::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 (CcSchedule object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcSchedulePeer::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 + CcSchedulePeer::NUM_COLUMNS; + } else { + $cls = CcSchedulePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSchedulePeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcSchedulePeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcSchedulePeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcScheduleTableMap()); + } + } + + /** + * 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 ? CcSchedulePeer::CLASS_DEFAULT : CcSchedulePeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcSchedule or Criteria object. + * + * @param mixed $values Criteria or CcSchedule 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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcSchedule object + } + + + // 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 CcSchedule or Criteria object. + * + * @param mixed $values Criteria or CcSchedule 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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcSchedulePeer::ID); + $value = $criteria->remove(CcSchedulePeer::ID); + if ($value) { + $selectCriteria->add(CcSchedulePeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcSchedulePeer::TABLE_NAME); + } + + } else { // $values is CcSchedule 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_schedule 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(CcSchedulePeer::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(CcSchedulePeer::TABLE_NAME, $con, CcSchedulePeer::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). + CcSchedulePeer::clearInstancePool(); + CcSchedulePeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcSchedule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcSchedule 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(CcSchedulePeer::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. + CcSchedulePeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcSchedule) { // it's a model object + // invalidate the cache for this single object + CcSchedulePeer::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(CcSchedulePeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcSchedulePeer::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); + CcSchedulePeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcSchedule 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 CcSchedule $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(CcSchedule $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcSchedulePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, CcSchedulePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcSchedule + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcSchedulePeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcSchedulePeer::DATABASE_NAME); + $criteria->add(CcSchedulePeer::ID, $pk); + + $v = CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcSchedulePeer::DATABASE_NAME); + $criteria->add(CcSchedulePeer::ID, $pks, Criteria::IN); + $objs = CcSchedulePeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcSchedulePeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcSchedulePeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcScheduleQuery.php b/application/models/campcaster/om/BaseCcScheduleQuery.php new file mode 100644 index 000000000..22435bf77 --- /dev/null +++ b/application/models/campcaster/om/BaseCcScheduleQuery.php @@ -0,0 +1,515 @@ +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 CcSchedule|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcSchedulePeer::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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcSchedulePeer::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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcSchedulePeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param string|array $id 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcSchedulePeer::ID, $id, $comparison); + } + + /** + * Filter the query on the playlist_id column + * + * @param int|array $playlistId 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByPlaylistId($playlistId = null, $comparison = null) + { + if (is_array($playlistId)) { + $useMinMax = false; + if (isset($playlistId['min'])) { + $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $playlistId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playlistId['max'])) { + $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $playlistId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $playlistId, $comparison); + } + + /** + * Filter the query on the starts column + * + * @param string|array $starts 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByStarts($starts = null, $comparison = null) + { + if (is_array($starts)) { + $useMinMax = false; + if (isset($starts['min'])) { + $this->addUsingAlias(CcSchedulePeer::STARTS, $starts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($starts['max'])) { + $this->addUsingAlias(CcSchedulePeer::STARTS, $starts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::STARTS, $starts, $comparison); + } + + /** + * Filter the query on the ends column + * + * @param string|array $ends 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByEnds($ends = null, $comparison = null) + { + if (is_array($ends)) { + $useMinMax = false; + if (isset($ends['min'])) { + $this->addUsingAlias(CcSchedulePeer::ENDS, $ends['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ends['max'])) { + $this->addUsingAlias(CcSchedulePeer::ENDS, $ends['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::ENDS, $ends, $comparison); + } + + /** + * Filter the query on the group_id column + * + * @param int|array $groupId 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByGroupId($groupId = null, $comparison = null) + { + if (is_array($groupId)) { + $useMinMax = false; + if (isset($groupId['min'])) { + $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($groupId['max'])) { + $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $groupId, $comparison); + } + + /** + * Filter the query on the file_id column + * + * @param int|array $fileId 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByFileId($fileId = null, $comparison = null) + { + if (is_array($fileId)) { + $useMinMax = false; + if (isset($fileId['min'])) { + $this->addUsingAlias(CcSchedulePeer::FILE_ID, $fileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fileId['max'])) { + $this->addUsingAlias(CcSchedulePeer::FILE_ID, $fileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::FILE_ID, $fileId, $comparison); + } + + /** + * Filter the query on the clip_length column + * + * @param string|array $clipLength 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByClipLength($clipLength = null, $comparison = null) + { + if (is_array($clipLength)) { + $useMinMax = false; + if (isset($clipLength['min'])) { + $this->addUsingAlias(CcSchedulePeer::CLIP_LENGTH, $clipLength['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($clipLength['max'])) { + $this->addUsingAlias(CcSchedulePeer::CLIP_LENGTH, $clipLength['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::CLIP_LENGTH, $clipLength, $comparison); + } + + /** + * Filter the query on the fade_in column + * + * @param string|array $fadeIn 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByFadeIn($fadeIn = null, $comparison = null) + { + if (is_array($fadeIn)) { + $useMinMax = false; + if (isset($fadeIn['min'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_IN, $fadeIn['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fadeIn['max'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_IN, $fadeIn['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::FADE_IN, $fadeIn, $comparison); + } + + /** + * Filter the query on the fade_out column + * + * @param string|array $fadeOut 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByFadeOut($fadeOut = null, $comparison = null) + { + if (is_array($fadeOut)) { + $useMinMax = false; + if (isset($fadeOut['min'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $fadeOut['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fadeOut['max'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $fadeOut['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $fadeOut, $comparison); + } + + /** + * Filter the query on the cue_in column + * + * @param string|array $cueIn 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByCueIn($cueIn = null, $comparison = null) + { + if (is_array($cueIn)) { + $useMinMax = false; + if (isset($cueIn['min'])) { + $this->addUsingAlias(CcSchedulePeer::CUE_IN, $cueIn['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($cueIn['max'])) { + $this->addUsingAlias(CcSchedulePeer::CUE_IN, $cueIn['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::CUE_IN, $cueIn, $comparison); + } + + /** + * Filter the query on the cue_out column + * + * @param string|array $cueOut 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByCueOut($cueOut = null, $comparison = null) + { + if (is_array($cueOut)) { + $useMinMax = false; + if (isset($cueOut['min'])) { + $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $cueOut['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($cueOut['max'])) { + $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $cueOut['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $cueOut, $comparison); + } + + /** + * Exclude object from result + * + * @param CcSchedule $ccSchedule Object to remove from the list of results + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function prune($ccSchedule = null) + { + if ($ccSchedule) { + $this->addUsingAlias(CcSchedulePeer::ID, $ccSchedule->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcScheduleQuery diff --git a/application/models/campcaster/om/BaseCcSess.php b/application/models/campcaster/om/BaseCcSess.php new file mode 100644 index 000000000..a68aa8e12 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSess.php @@ -0,0 +1,949 @@ +sessid; + } + + /** + * Get the [userid] column value. + * + * @return int + */ + public function getUserid() + { + return $this->userid; + } + + /** + * Get the [login] column value. + * + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Get the [optionally formatted] temporal [ts] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getTs($format = 'Y-m-d H:i:s') + { + if ($this->ts === null) { + return null; + } + + + + try { + $dt = new DateTime($this->ts); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ts, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [sessid] column. + * + * @param string $v new value + * @return CcSess The current object (for fluent API support) + */ + public function setSessid($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->sessid !== $v) { + $this->sessid = $v; + $this->modifiedColumns[] = CcSessPeer::SESSID; + } + + return $this; + } // setSessid() + + /** + * Set the value of [userid] column. + * + * @param int $v new value + * @return CcSess The current object (for fluent API support) + */ + public function setUserid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->userid !== $v) { + $this->userid = $v; + $this->modifiedColumns[] = CcSessPeer::USERID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) { + $this->aCcSubjs = null; + } + + return $this; + } // setUserid() + + /** + * Set the value of [login] column. + * + * @param string $v new value + * @return CcSess The current object (for fluent API support) + */ + public function setLogin($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->login !== $v) { + $this->login = $v; + $this->modifiedColumns[] = CcSessPeer::LOGIN; + } + + return $this; + } // setLogin() + + /** + * Sets the value of [ts] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSess The current object (for fluent API support) + */ + public function setTs($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->ts !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->ts !== null && $tmpDt = new DateTime($this->ts)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->ts = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcSessPeer::TS; + } + } // if either are not null + + return $this; + } // setTs() + + /** + * 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->sessid = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->userid = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->login = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->ts = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = CcSessPeer::NUM_COLUMNS - CcSessPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcSess 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->aCcSubjs !== null && $this->userid !== $this->aCcSubjs->getId()) { + $this->aCcSubjs = 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(CcSessPeer::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 = CcSessPeer::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->aCcSubjs = 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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcSessQuery::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(CcSessPeer::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); + CcSessPeer::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->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setNew(false); + } else { + $affectedRows += CcSessPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
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->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcSessPeer::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 = CcSessPeer::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->getSessid(); + break; + case 1: + return $this->getUserid(); + break; + case 2: + return $this->getLogin(); + break; + case 3: + return $this->getTs(); + 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 = CcSessPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getSessid(), + $keys[1] => $this->getUserid(), + $keys[2] => $this->getLogin(), + $keys[3] => $this->getTs(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->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 = CcSessPeer::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->setSessid($value); + break; + case 1: + $this->setUserid($value); + break; + case 2: + $this->setLogin($value); + break; + case 3: + $this->setTs($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 = CcSessPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setSessid($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUserid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setLogin($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTs($arr[$keys[3]]); + } + + /** + * 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(CcSessPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcSessPeer::SESSID)) $criteria->add(CcSessPeer::SESSID, $this->sessid); + if ($this->isColumnModified(CcSessPeer::USERID)) $criteria->add(CcSessPeer::USERID, $this->userid); + if ($this->isColumnModified(CcSessPeer::LOGIN)) $criteria->add(CcSessPeer::LOGIN, $this->login); + if ($this->isColumnModified(CcSessPeer::TS)) $criteria->add(CcSessPeer::TS, $this->ts); + + 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(CcSessPeer::DATABASE_NAME); + $criteria->add(CcSessPeer::SESSID, $this->sessid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getSessid(); + } + + /** + * Generic method to set the primary key (sessid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setSessid($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getSessid(); + } + + /** + * 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 CcSess (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->setSessid($this->sessid); + $copyObj->setUserid($this->userid); + $copyObj->setLogin($this->login); + $copyObj->setTs($this->ts); + + $copyObj->setNew(true); + } + + /** + * 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 CcSess 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 CcSessPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcSessPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcSess The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setUserid(NULL); + } else { + $this->setUserid($v->getId()); + } + + $this->aCcSubjs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSubjs object, it will not be re-added. + if ($v !== null) { + $v->addCcSess($this); + } + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO Optional Connection object. + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null) + { + if ($this->aCcSubjs === null && ($this->userid !== null)) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->userid, $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->aCcSubjs->addCcSesss($this); + */ + } + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->sessid = null; + $this->userid = null; + $this->login = null; + $this->ts = 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->aCcSubjs = 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); + } + +} // BaseCcSess diff --git a/application/models/campcaster/om/BaseCcSessPeer.php b/application/models/campcaster/om/BaseCcSessPeer.php new file mode 100644 index 000000000..0ca095e21 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSessPeer.php @@ -0,0 +1,979 @@ + array ('Sessid', 'Userid', 'Login', 'Ts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('sessid', 'userid', 'login', 'ts', ), + BasePeer::TYPE_COLNAME => array (self::SESSID, self::USERID, self::LOGIN, self::TS, ), + BasePeer::TYPE_RAW_COLNAME => array ('SESSID', 'USERID', 'LOGIN', 'TS', ), + BasePeer::TYPE_FIELDNAME => array ('sessid', 'userid', 'login', 'ts', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * 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 ('Sessid' => 0, 'Userid' => 1, 'Login' => 2, 'Ts' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('sessid' => 0, 'userid' => 1, 'login' => 2, 'ts' => 3, ), + BasePeer::TYPE_COLNAME => array (self::SESSID => 0, self::USERID => 1, self::LOGIN => 2, self::TS => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('SESSID' => 0, 'USERID' => 1, 'LOGIN' => 2, 'TS' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('sessid' => 0, 'userid' => 1, 'login' => 2, 'ts' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * 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. CcSessPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcSessPeer::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(CcSessPeer::SESSID); + $criteria->addSelectColumn(CcSessPeer::USERID); + $criteria->addSelectColumn(CcSessPeer::LOGIN); + $criteria->addSelectColumn(CcSessPeer::TS); + } else { + $criteria->addSelectColumn($alias . '.SESSID'); + $criteria->addSelectColumn($alias . '.USERID'); + $criteria->addSelectColumn($alias . '.LOGIN'); + $criteria->addSelectColumn($alias . '.TS'); + } + } + + /** + * 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(CcSessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSessPeer::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(CcSessPeer::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 CcSess + * @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 = CcSessPeer::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 CcSessPeer::populateObjects(CcSessPeer::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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcSessPeer::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 CcSess $value A CcSess object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcSess $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getSessid(); + } // 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 CcSess object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSess) { + $key = (string) $value->getSessid(); + } 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 CcSess 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 CcSess 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_sess + * 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 (string) $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 = CcSessPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcSessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcSessPeer::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; + CcSessPeer::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 (CcSess object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcSessPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcSessPeer::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 + CcSessPeer::NUM_COLUMNS; + } else { + $cls = CcSessPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSessPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcSubjs 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 doCountJoinCcSubjs(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(CcSessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSessPeer::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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSessPeer::USERID, CcSubjsPeer::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 CcSess objects pre-filled with their CcSubjs 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 CcSess objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSubjs(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); + } + + CcSessPeer::addSelectColumns($criteria); + $startcol = (CcSessPeer::NUM_COLUMNS - CcSessPeer::NUM_LAZY_LOAD_COLUMNS); + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcSessPeer::USERID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSessPeer::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 = CcSessPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSessPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcSess) to $obj2 (CcSubjs) + $obj2->addCcSess($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(CcSessPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSessPeer::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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSessPeer::USERID, CcSubjsPeer::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 CcSess 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 CcSess 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); + } + + CcSessPeer::addSelectColumns($criteria); + $startcol2 = (CcSessPeer::NUM_COLUMNS - CcSessPeer::NUM_LAZY_LOAD_COLUMNS); + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcSessPeer::USERID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSessPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSessPeer::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 = CcSessPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSessPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSubjs rows + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcSess) to the collection in $obj2 (CcSubjs) + $obj2->addCcSess($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(BaseCcSessPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcSessPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcSessTableMap()); + } + } + + /** + * 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 ? CcSessPeer::CLASS_DEFAULT : CcSessPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcSess or Criteria object. + * + * @param mixed $values Criteria or CcSess 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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcSess object + } + + + // 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 CcSess or Criteria object. + * + * @param mixed $values Criteria or CcSess 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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcSessPeer::SESSID); + $value = $criteria->remove(CcSessPeer::SESSID); + if ($value) { + $selectCriteria->add(CcSessPeer::SESSID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcSessPeer::TABLE_NAME); + } + + } else { // $values is CcSess 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_sess 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(CcSessPeer::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(CcSessPeer::TABLE_NAME, $con, CcSessPeer::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). + CcSessPeer::clearInstancePool(); + CcSessPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcSess or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcSess 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(CcSessPeer::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. + CcSessPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcSess) { // it's a model object + // invalidate the cache for this single object + CcSessPeer::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(CcSessPeer::SESSID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcSessPeer::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); + CcSessPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcSess 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 CcSess $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(CcSess $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcSessPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcSessPeer::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(CcSessPeer::DATABASE_NAME, CcSessPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcSess + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcSessPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcSessPeer::DATABASE_NAME); + $criteria->add(CcSessPeer::SESSID, $pk); + + $v = CcSessPeer::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(CcSessPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcSessPeer::DATABASE_NAME); + $criteria->add(CcSessPeer::SESSID, $pks, Criteria::IN); + $objs = CcSessPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcSessPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcSessPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcSessQuery.php b/application/models/campcaster/om/BaseCcSessQuery.php new file mode 100644 index 000000000..f2462c695 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSessQuery.php @@ -0,0 +1,334 @@ +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 CcSess|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcSessPeer::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 CcSessQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcSessPeer::SESSID, $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 CcSessQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcSessPeer::SESSID, $keys, Criteria::IN); + } + + /** + * Filter the query on the sessid column + * + * @param string $sessid 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 CcSessQuery The current query, for fluid interface + */ + public function filterBySessid($sessid = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($sessid)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $sessid)) { + $sessid = str_replace('*', '%', $sessid); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSessPeer::SESSID, $sessid, $comparison); + } + + /** + * Filter the query on the userid column + * + * @param int|array $userid 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 CcSessQuery The current query, for fluid interface + */ + public function filterByUserid($userid = null, $comparison = null) + { + if (is_array($userid)) { + $useMinMax = false; + if (isset($userid['min'])) { + $this->addUsingAlias(CcSessPeer::USERID, $userid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($userid['max'])) { + $this->addUsingAlias(CcSessPeer::USERID, $userid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSessPeer::USERID, $userid, $comparison); + } + + /** + * Filter the query on the login column + * + * @param string $login 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 CcSessQuery The current query, for fluid interface + */ + public function filterByLogin($login = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($login)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $login)) { + $login = str_replace('*', '%', $login); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSessPeer::LOGIN, $login, $comparison); + } + + /** + * Filter the query on the ts column + * + * @param string|array $ts 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 CcSessQuery The current query, for fluid interface + */ + public function filterByTs($ts = null, $comparison = null) + { + if (is_array($ts)) { + $useMinMax = false; + if (isset($ts['min'])) { + $this->addUsingAlias(CcSessPeer::TS, $ts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ts['max'])) { + $this->addUsingAlias(CcSessPeer::TS, $ts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSessPeer::TS, $ts, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs $ccSubjs the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSessQuery The current query, for fluid interface + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + return $this + ->addUsingAlias(CcSessPeer::USERID, $ccSubjs->getId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSubjs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSessQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjs'); + + // 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, 'CcSubjs'); + } + + return $this; + } + + /** + * Use the CcSubjs relation CcSubjs 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 CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcSess $ccSess Object to remove from the list of results + * + * @return CcSessQuery The current query, for fluid interface + */ + public function prune($ccSess = null) + { + if ($ccSess) { + $this->addUsingAlias(CcSessPeer::SESSID, $ccSess->getSessid(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcSessQuery diff --git a/application/models/campcaster/om/BaseCcShow.php b/application/models/campcaster/om/BaseCcShow.php new file mode 100644 index 000000000..d0df93fc4 --- /dev/null +++ b/application/models/campcaster/om/BaseCcShow.php @@ -0,0 +1,1287 @@ +name = ''; + } + + /** + * Initializes internal state of BaseCcShow object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + return $this->id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getDbName() + { + return $this->name; + } + + /** + * Get the [optionally formatted] temporal [first_show] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbFirstShow($format = '%x') + { + if ($this->first_show === null) { + return null; + } + + + + try { + $dt = new DateTime($this->first_show); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->first_show, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [last_show] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbLastShow($format = '%x') + { + if ($this->last_show === null) { + return null; + } + + + + try { + $dt = new DateTime($this->last_show); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_show, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [start_time] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbStartTime($format = '%X') + { + if ($this->start_time === null) { + return null; + } + + + + try { + $dt = new DateTime($this->start_time); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->start_time, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [end_time] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbEndTime($format = '%X') + { + if ($this->end_time === null) { + return null; + } + + + + try { + $dt = new DateTime($this->end_time); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->end_time, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [repeats] column value. + * + * @return int + */ + public function getDbRepeats() + { + return $this->repeats; + } + + /** + * Get the [day] column value. + * + * @return int + */ + public function getDbDay() + { + return $this->day; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDbDescription() + { + return $this->description; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShow 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[] = CcShowPeer::ID; + } + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v || $this->isNew()) { + $this->name = $v; + $this->modifiedColumns[] = CcShowPeer::NAME; + } + + return $this; + } // setDbName() + + /** + * Sets the value of [first_show] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcShow The current object (for fluent API support) + */ + public function setDbFirstShow($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->first_show !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->first_show !== null && $tmpDt = new DateTime($this->first_show)) ? $tmpDt->format('Y-m-d') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->first_show = ($dt ? $dt->format('Y-m-d') : null); + $this->modifiedColumns[] = CcShowPeer::FIRST_SHOW; + } + } // if either are not null + + return $this; + } // setDbFirstShow() + + /** + * Sets the value of [last_show] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcShow The current object (for fluent API support) + */ + public function setDbLastShow($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->last_show !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->last_show !== null && $tmpDt = new DateTime($this->last_show)) ? $tmpDt->format('Y-m-d') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->last_show = ($dt ? $dt->format('Y-m-d') : null); + $this->modifiedColumns[] = CcShowPeer::LAST_SHOW; + } + } // if either are not null + + return $this; + } // setDbLastShow() + + /** + * Sets the value of [start_time] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcShow The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->start_time !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->start_time = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcShowPeer::START_TIME; + } + } // if either are not null + + return $this; + } // setDbStartTime() + + /** + * Sets the value of [end_time] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcShow The current object (for fluent API support) + */ + public function setDbEndTime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->end_time !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->end_time !== null && $tmpDt = new DateTime($this->end_time)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->end_time = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcShowPeer::END_TIME; + } + } // if either are not null + + return $this; + } // setDbEndTime() + + /** + * Set the value of [repeats] column. + * + * @param int $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbRepeats($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->repeats !== $v) { + $this->repeats = $v; + $this->modifiedColumns[] = CcShowPeer::REPEATS; + } + + return $this; + } // setDbRepeats() + + /** + * Set the value of [day] column. + * + * @param int $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbDay($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->day !== $v) { + $this->day = $v; + $this->modifiedColumns[] = CcShowPeer::DAY; + } + + return $this; + } // setDbDay() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcShowPeer::DESCRIPTION; + } + + return $this; + } // setDbDescription() + + /** + * 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() + { + if ($this->name !== '') { + return false; + } + + // 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->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->first_show = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->last_show = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->start_time = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->end_time = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcShow 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() + { + + } // 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(CcShowPeer::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 = CcShowPeer::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? + + } // 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(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcShowQuery::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(CcShowPeer::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); + CcShowPeer::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; + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcShowPeer::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(CcShowPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows = CcShowPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcShowPeer::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 = CcShowPeer::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->getDbName(); + break; + case 2: + return $this->getDbFirstShow(); + break; + case 3: + return $this->getDbLastShow(); + break; + case 4: + return $this->getDbStartTime(); + break; + case 5: + return $this->getDbEndTime(); + break; + case 6: + return $this->getDbRepeats(); + break; + case 7: + return $this->getDbDay(); + break; + case 8: + return $this->getDbDescription(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcShowPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbFirstShow(), + $keys[3] => $this->getDbLastShow(), + $keys[4] => $this->getDbStartTime(), + $keys[5] => $this->getDbEndTime(), + $keys[6] => $this->getDbRepeats(), + $keys[7] => $this->getDbDay(), + $keys[8] => $this->getDbDescription(), + ); + 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 = CcShowPeer::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->setDbName($value); + break; + case 2: + $this->setDbFirstShow($value); + break; + case 3: + $this->setDbLastShow($value); + break; + case 4: + $this->setDbStartTime($value); + break; + case 5: + $this->setDbEndTime($value); + break; + case 6: + $this->setDbRepeats($value); + break; + case 7: + $this->setDbDay($value); + break; + case 8: + $this->setDbDescription($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 = CcShowPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbFirstShow($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbLastShow($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbStartTime($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbEndTime($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]); + } + + /** + * 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(CcShowPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowPeer::ID)) $criteria->add(CcShowPeer::ID, $this->id); + if ($this->isColumnModified(CcShowPeer::NAME)) $criteria->add(CcShowPeer::NAME, $this->name); + if ($this->isColumnModified(CcShowPeer::FIRST_SHOW)) $criteria->add(CcShowPeer::FIRST_SHOW, $this->first_show); + if ($this->isColumnModified(CcShowPeer::LAST_SHOW)) $criteria->add(CcShowPeer::LAST_SHOW, $this->last_show); + if ($this->isColumnModified(CcShowPeer::START_TIME)) $criteria->add(CcShowPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcShowPeer::END_TIME)) $criteria->add(CcShowPeer::END_TIME, $this->end_time); + if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats); + if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day); + if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); + + 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(CcShowPeer::DATABASE_NAME); + $criteria->add(CcShowPeer::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 CcShow (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->setDbName($this->name); + $copyObj->setDbFirstShow($this->first_show); + $copyObj->setDbLastShow($this->last_show); + $copyObj->setDbStartTime($this->start_time); + $copyObj->setDbEndTime($this->end_time); + $copyObj->setDbRepeats($this->repeats); + $copyObj->setDbDay($this->day); + $copyObj->setDbDescription($this->description); + + $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 CcShow 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 CcShowPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->first_show = null; + $this->last_show = null; + $this->start_time = null; + $this->end_time = null; + $this->repeats = null; + $this->day = null; + $this->description = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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) + + } + + /** + * 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); + } + +} // BaseCcShow diff --git a/application/models/campcaster/om/BaseCcShowPeer.php b/application/models/campcaster/om/BaseCcShowPeer.php new file mode 100644 index 000000000..f407adde1 --- /dev/null +++ b/application/models/campcaster/om/BaseCcShowPeer.php @@ -0,0 +1,774 @@ + array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * 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. CcShowPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowPeer::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(CcShowPeer::ID); + $criteria->addSelectColumn(CcShowPeer::NAME); + $criteria->addSelectColumn(CcShowPeer::FIRST_SHOW); + $criteria->addSelectColumn(CcShowPeer::LAST_SHOW); + $criteria->addSelectColumn(CcShowPeer::START_TIME); + $criteria->addSelectColumn(CcShowPeer::END_TIME); + $criteria->addSelectColumn(CcShowPeer::REPEATS); + $criteria->addSelectColumn(CcShowPeer::DAY); + $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.NAME'); + $criteria->addSelectColumn($alias . '.FIRST_SHOW'); + $criteria->addSelectColumn($alias . '.LAST_SHOW'); + $criteria->addSelectColumn($alias . '.START_TIME'); + $criteria->addSelectColumn($alias . '.END_TIME'); + $criteria->addSelectColumn($alias . '.REPEATS'); + $criteria->addSelectColumn($alias . '.DAY'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + } + } + + /** + * 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(CcShowPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowPeer::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(CcShowPeer::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 CcShow + * @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 = CcShowPeer::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 CcShowPeer::populateObjects(CcShowPeer::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(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowPeer::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 CcShow $value A CcShow object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcShow $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 CcShow object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShow) { + $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 CcShow 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 CcShow 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_show + * 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 = CcShowPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowPeer::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; + CcShowPeer::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 (CcShow object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowPeer::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 + CcShowPeer::NUM_COLUMNS; + } else { + $cls = CcShowPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcShowPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcShowTableMap()); + } + } + + /** + * 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 ? CcShowPeer::CLASS_DEFAULT : CcShowPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcShow or Criteria object. + * + * @param mixed $values Criteria or CcShow 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(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShow object + } + + if ($criteria->containsKey(CcShowPeer::ID) && $criteria->keyContainsValue(CcShowPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowPeer::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 CcShow or Criteria object. + * + * @param mixed $values Criteria or CcShow 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(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowPeer::ID); + $value = $criteria->remove(CcShowPeer::ID); + if ($value) { + $selectCriteria->add(CcShowPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowPeer::TABLE_NAME); + } + + } else { // $values is CcShow 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_show 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(CcShowPeer::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(CcShowPeer::TABLE_NAME, $con, CcShowPeer::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). + CcShowPeer::clearInstancePool(); + CcShowPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcShow or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShow 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(CcShowPeer::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. + CcShowPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShow) { // it's a model object + // invalidate the cache for this single object + CcShowPeer::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(CcShowPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowPeer::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); + CcShowPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShow 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 CcShow $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(CcShow $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowPeer::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(CcShowPeer::DATABASE_NAME, CcShowPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShow + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowPeer::DATABASE_NAME); + $criteria->add(CcShowPeer::ID, $pk); + + $v = CcShowPeer::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(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowPeer::DATABASE_NAME); + $criteria->add(CcShowPeer::ID, $pks, Criteria::IN); + $objs = CcShowPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcShowPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcShowPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcShowQuery.php b/application/models/campcaster/om/BaseCcShowQuery.php new file mode 100644 index 000000000..7dd2829e6 --- /dev/null +++ b/application/models/campcaster/om/BaseCcShowQuery.php @@ -0,0 +1,427 @@ +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 CcShow|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcShowPeer::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 CcShowQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcShowPeer::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 CcShowQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcShowPeer::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 CcShowQuery 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(CcShowPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the name column + * + * @param string $dbName 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbName($dbName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbName)) { + $dbName = str_replace('*', '%', $dbName); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the first_show column + * + * @param string|array $dbFirstShow 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbFirstShow($dbFirstShow = null, $comparison = null) + { + if (is_array($dbFirstShow)) { + $useMinMax = false; + if (isset($dbFirstShow['min'])) { + $this->addUsingAlias(CcShowPeer::FIRST_SHOW, $dbFirstShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFirstShow['max'])) { + $this->addUsingAlias(CcShowPeer::FIRST_SHOW, $dbFirstShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::FIRST_SHOW, $dbFirstShow, $comparison); + } + + /** + * Filter the query on the last_show column + * + * @param string|array $dbLastShow 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbLastShow($dbLastShow = null, $comparison = null) + { + if (is_array($dbLastShow)) { + $useMinMax = false; + if (isset($dbLastShow['min'])) { + $this->addUsingAlias(CcShowPeer::LAST_SHOW, $dbLastShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLastShow['max'])) { + $this->addUsingAlias(CcShowPeer::LAST_SHOW, $dbLastShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::LAST_SHOW, $dbLastShow, $comparison); + } + + /** + * Filter the query on the start_time column + * + * @param string|array $dbStartTime 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbStartTime($dbStartTime = null, $comparison = null) + { + if (is_array($dbStartTime)) { + $useMinMax = false; + if (isset($dbStartTime['min'])) { + $this->addUsingAlias(CcShowPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcShowPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the end_time column + * + * @param string|array $dbEndTime 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbEndTime($dbEndTime = null, $comparison = null) + { + if (is_array($dbEndTime)) { + $useMinMax = false; + if (isset($dbEndTime['min'])) { + $this->addUsingAlias(CcShowPeer::END_TIME, $dbEndTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEndTime['max'])) { + $this->addUsingAlias(CcShowPeer::END_TIME, $dbEndTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::END_TIME, $dbEndTime, $comparison); + } + + /** + * Filter the query on the repeats column + * + * @param int|array $dbRepeats 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbRepeats($dbRepeats = null, $comparison = null) + { + if (is_array($dbRepeats)) { + $useMinMax = false; + if (isset($dbRepeats['min'])) { + $this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRepeats['max'])) { + $this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::REPEATS, $dbRepeats, $comparison); + } + + /** + * Filter the query on the day column + * + * @param int|array $dbDay 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbDay($dbDay = null, $comparison = null) + { + if (is_array($dbDay)) { + $useMinMax = false; + if (isset($dbDay['min'])) { + $this->addUsingAlias(CcShowPeer::DAY, $dbDay['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbDay['max'])) { + $this->addUsingAlias(CcShowPeer::DAY, $dbDay['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowPeer::DAY, $dbDay, $comparison); + } + + /** + * Filter the query on the description column + * + * @param string $dbDescription 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbDescription($dbDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDescription)) { + $dbDescription = str_replace('*', '%', $dbDescription); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison); + } + + /** + * Exclude object from result + * + * @param CcShow $ccShow Object to remove from the list of results + * + * @return CcShowQuery The current query, for fluid interface + */ + public function prune($ccShow = null) + { + if ($ccShow) { + $this->addUsingAlias(CcShowPeer::ID, $ccShow->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcShowQuery diff --git a/application/models/campcaster/om/BaseCcSmemb.php b/application/models/campcaster/om/BaseCcSmemb.php new file mode 100644 index 000000000..bb98b5c1e --- /dev/null +++ b/application/models/campcaster/om/BaseCcSmemb.php @@ -0,0 +1,891 @@ +uid = 0; + $this->gid = 0; + $this->level = 0; + } + + /** + * Initializes internal state of BaseCcSmemb object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Get the [uid] column value. + * + * @return int + */ + public function getUid() + { + return $this->uid; + } + + /** + * Get the [gid] column value. + * + * @return int + */ + public function getGid() + { + return $this->gid; + } + + /** + * Get the [level] column value. + * + * @return int + */ + public function getLevel() + { + return $this->level; + } + + /** + * Get the [mid] column value. + * + * @return int + */ + public function getMid() + { + return $this->mid; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcSmemb The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSmembPeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [uid] column. + * + * @param int $v new value + * @return CcSmemb The current object (for fluent API support) + */ + public function setUid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->uid !== $v || $this->isNew()) { + $this->uid = $v; + $this->modifiedColumns[] = CcSmembPeer::UID; + } + + return $this; + } // setUid() + + /** + * Set the value of [gid] column. + * + * @param int $v new value + * @return CcSmemb The current object (for fluent API support) + */ + public function setGid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->gid !== $v || $this->isNew()) { + $this->gid = $v; + $this->modifiedColumns[] = CcSmembPeer::GID; + } + + return $this; + } // setGid() + + /** + * Set the value of [level] column. + * + * @param int $v new value + * @return CcSmemb The current object (for fluent API support) + */ + public function setLevel($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->level !== $v || $this->isNew()) { + $this->level = $v; + $this->modifiedColumns[] = CcSmembPeer::LEVEL; + } + + return $this; + } // setLevel() + + /** + * Set the value of [mid] column. + * + * @param int $v new value + * @return CcSmemb The current object (for fluent API support) + */ + public function setMid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->mid !== $v) { + $this->mid = $v; + $this->modifiedColumns[] = CcSmembPeer::MID; + } + + return $this; + } // setMid() + + /** + * 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() + { + if ($this->uid !== 0) { + return false; + } + + if ($this->gid !== 0) { + return false; + } + + if ($this->level !== 0) { + return false; + } + + // 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->uid = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->gid = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->level = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->mid = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = CcSmembPeer::NUM_COLUMNS - CcSmembPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcSmemb 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() + { + + } // 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(CcSmembPeer::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 = CcSmembPeer::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? + + } // 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(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcSmembQuery::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(CcSmembPeer::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); + CcSmembPeer::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; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcSmembPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcSmembPeer::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 = CcSmembPeer::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->getId(); + break; + case 1: + return $this->getUid(); + break; + case 2: + return $this->getGid(); + break; + case 3: + return $this->getLevel(); + break; + case 4: + return $this->getMid(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcSmembPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getUid(), + $keys[2] => $this->getGid(), + $keys[3] => $this->getLevel(), + $keys[4] => $this->getMid(), + ); + 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 = CcSmembPeer::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->setId($value); + break; + case 1: + $this->setUid($value); + break; + case 2: + $this->setGid($value); + break; + case 3: + $this->setLevel($value); + break; + case 4: + $this->setMid($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 = CcSmembPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUid($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setGid($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setLevel($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setMid($arr[$keys[4]]); + } + + /** + * 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(CcSmembPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcSmembPeer::ID)) $criteria->add(CcSmembPeer::ID, $this->id); + if ($this->isColumnModified(CcSmembPeer::UID)) $criteria->add(CcSmembPeer::UID, $this->uid); + if ($this->isColumnModified(CcSmembPeer::GID)) $criteria->add(CcSmembPeer::GID, $this->gid); + if ($this->isColumnModified(CcSmembPeer::LEVEL)) $criteria->add(CcSmembPeer::LEVEL, $this->level); + if ($this->isColumnModified(CcSmembPeer::MID)) $criteria->add(CcSmembPeer::MID, $this->mid); + + 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(CcSmembPeer::DATABASE_NAME); + $criteria->add(CcSmembPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcSmemb (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->setId($this->id); + $copyObj->setUid($this->uid); + $copyObj->setGid($this->gid); + $copyObj->setLevel($this->level); + $copyObj->setMid($this->mid); + + $copyObj->setNew(true); + } + + /** + * 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 CcSmemb 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 CcSmembPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcSmembPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->uid = null; + $this->gid = null; + $this->level = null; + $this->mid = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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) + + } + + /** + * 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); + } + +} // BaseCcSmemb diff --git a/application/models/campcaster/om/BaseCcSmembPeer.php b/application/models/campcaster/om/BaseCcSmembPeer.php new file mode 100644 index 000000000..152440c7e --- /dev/null +++ b/application/models/campcaster/om/BaseCcSmembPeer.php @@ -0,0 +1,750 @@ + array ('Id', 'Uid', 'Gid', 'Level', 'Mid', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'uid', 'gid', 'level', 'mid', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::UID, self::GID, self::LEVEL, self::MID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'UID', 'GID', 'LEVEL', 'MID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'uid', 'gid', 'level', 'mid', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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 ('Id' => 0, 'Uid' => 1, 'Gid' => 2, 'Level' => 3, 'Mid' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'uid' => 1, 'gid' => 2, 'level' => 3, 'mid' => 4, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::UID => 1, self::GID => 2, self::LEVEL => 3, self::MID => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'UID' => 1, 'GID' => 2, 'LEVEL' => 3, 'MID' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'uid' => 1, 'gid' => 2, 'level' => 3, 'mid' => 4, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) + ); + + /** + * 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. CcSmembPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcSmembPeer::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(CcSmembPeer::ID); + $criteria->addSelectColumn(CcSmembPeer::UID); + $criteria->addSelectColumn(CcSmembPeer::GID); + $criteria->addSelectColumn(CcSmembPeer::LEVEL); + $criteria->addSelectColumn(CcSmembPeer::MID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.UID'); + $criteria->addSelectColumn($alias . '.GID'); + $criteria->addSelectColumn($alias . '.LEVEL'); + $criteria->addSelectColumn($alias . '.MID'); + } + } + + /** + * 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(CcSmembPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSmembPeer::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(CcSmembPeer::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 CcSmemb + * @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 = CcSmembPeer::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 CcSmembPeer::populateObjects(CcSmembPeer::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(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcSmembPeer::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 CcSmemb $value A CcSmemb object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcSmemb $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcSmemb object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSmemb) { + $key = (string) $value->getId(); + } 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 CcSmemb 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 CcSmemb 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_smemb + * 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 = CcSmembPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcSmembPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcSmembPeer::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; + CcSmembPeer::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 (CcSmemb object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcSmembPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcSmembPeer::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 + CcSmembPeer::NUM_COLUMNS; + } else { + $cls = CcSmembPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSmembPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcSmembPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcSmembPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcSmembTableMap()); + } + } + + /** + * 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 ? CcSmembPeer::CLASS_DEFAULT : CcSmembPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcSmemb or Criteria object. + * + * @param mixed $values Criteria or CcSmemb 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(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcSmemb object + } + + + // 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 CcSmemb or Criteria object. + * + * @param mixed $values Criteria or CcSmemb 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(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcSmembPeer::ID); + $value = $criteria->remove(CcSmembPeer::ID); + if ($value) { + $selectCriteria->add(CcSmembPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcSmembPeer::TABLE_NAME); + } + + } else { // $values is CcSmemb 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_smemb 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(CcSmembPeer::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(CcSmembPeer::TABLE_NAME, $con, CcSmembPeer::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). + CcSmembPeer::clearInstancePool(); + CcSmembPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcSmemb or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcSmemb 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(CcSmembPeer::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. + CcSmembPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcSmemb) { // it's a model object + // invalidate the cache for this single object + CcSmembPeer::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(CcSmembPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcSmembPeer::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); + CcSmembPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcSmemb 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 CcSmemb $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(CcSmemb $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcSmembPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcSmembPeer::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(CcSmembPeer::DATABASE_NAME, CcSmembPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcSmemb + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcSmembPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcSmembPeer::DATABASE_NAME); + $criteria->add(CcSmembPeer::ID, $pk); + + $v = CcSmembPeer::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(CcSmembPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcSmembPeer::DATABASE_NAME); + $criteria->add(CcSmembPeer::ID, $pks, Criteria::IN); + $objs = CcSmembPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcSmembPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcSmembPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcSmembQuery.php b/application/models/campcaster/om/BaseCcSmembQuery.php new file mode 100644 index 000000000..c0ac62c18 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSmembQuery.php @@ -0,0 +1,305 @@ +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 CcSmemb|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcSmembPeer::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 CcSmembQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcSmembPeer::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 CcSmembQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcSmembPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $id 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 CcSmembQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcSmembPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the uid column + * + * @param int|array $uid 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 CcSmembQuery The current query, for fluid interface + */ + public function filterByUid($uid = null, $comparison = null) + { + if (is_array($uid)) { + $useMinMax = false; + if (isset($uid['min'])) { + $this->addUsingAlias(CcSmembPeer::UID, $uid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($uid['max'])) { + $this->addUsingAlias(CcSmembPeer::UID, $uid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSmembPeer::UID, $uid, $comparison); + } + + /** + * Filter the query on the gid column + * + * @param int|array $gid 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 CcSmembQuery The current query, for fluid interface + */ + public function filterByGid($gid = null, $comparison = null) + { + if (is_array($gid)) { + $useMinMax = false; + if (isset($gid['min'])) { + $this->addUsingAlias(CcSmembPeer::GID, $gid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($gid['max'])) { + $this->addUsingAlias(CcSmembPeer::GID, $gid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSmembPeer::GID, $gid, $comparison); + } + + /** + * Filter the query on the level column + * + * @param int|array $level 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 CcSmembQuery The current query, for fluid interface + */ + public function filterByLevel($level = null, $comparison = null) + { + if (is_array($level)) { + $useMinMax = false; + if (isset($level['min'])) { + $this->addUsingAlias(CcSmembPeer::LEVEL, $level['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($level['max'])) { + $this->addUsingAlias(CcSmembPeer::LEVEL, $level['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSmembPeer::LEVEL, $level, $comparison); + } + + /** + * Filter the query on the mid column + * + * @param int|array $mid 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 CcSmembQuery The current query, for fluid interface + */ + public function filterByMid($mid = null, $comparison = null) + { + if (is_array($mid)) { + $useMinMax = false; + if (isset($mid['min'])) { + $this->addUsingAlias(CcSmembPeer::MID, $mid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($mid['max'])) { + $this->addUsingAlias(CcSmembPeer::MID, $mid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSmembPeer::MID, $mid, $comparison); + } + + /** + * Exclude object from result + * + * @param CcSmemb $ccSmemb Object to remove from the list of results + * + * @return CcSmembQuery The current query, for fluid interface + */ + public function prune($ccSmemb = null) + { + if ($ccSmemb) { + $this->addUsingAlias(CcSmembPeer::ID, $ccSmemb->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcSmembQuery diff --git a/application/models/campcaster/om/BaseCcSubjs.php b/application/models/campcaster/om/BaseCcSubjs.php new file mode 100644 index 000000000..58796a099 --- /dev/null +++ b/application/models/campcaster/om/BaseCcSubjs.php @@ -0,0 +1,1969 @@ +login = ''; + $this->pass = ''; + $this->type = 'U'; + $this->realname = ''; + } + + /** + * Initializes internal state of BaseCcSubjs object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Get the [login] column value. + * + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Get the [pass] column value. + * + * @return string + */ + public function getPass() + { + return $this->pass; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Get the [realname] column value. + * + * @return string + */ + public function getRealname() + { + return $this->realname; + } + + /** + * Get the [optionally formatted] temporal [lastlogin] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getLastlogin($format = 'Y-m-d H:i:s') + { + if ($this->lastlogin === null) { + return null; + } + + + + try { + $dt = new DateTime($this->lastlogin); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lastlogin, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [lastfail] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getLastfail($format = 'Y-m-d H:i:s') + { + if ($this->lastfail === null) { + return null; + } + + + + try { + $dt = new DateTime($this->lastfail); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lastfail, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSubjsPeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [login] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setLogin($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->login !== $v || $this->isNew()) { + $this->login = $v; + $this->modifiedColumns[] = CcSubjsPeer::LOGIN; + } + + return $this; + } // setLogin() + + /** + * Set the value of [pass] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setPass($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->pass !== $v || $this->isNew()) { + $this->pass = $v; + $this->modifiedColumns[] = CcSubjsPeer::PASS; + } + + return $this; + } // setPass() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v || $this->isNew()) { + $this->type = $v; + $this->modifiedColumns[] = CcSubjsPeer::TYPE; + } + + return $this; + } // setType() + + /** + * Set the value of [realname] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setRealname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->realname !== $v || $this->isNew()) { + $this->realname = $v; + $this->modifiedColumns[] = CcSubjsPeer::REALNAME; + } + + return $this; + } // setRealname() + + /** + * Sets the value of [lastlogin] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSubjs The current object (for fluent API support) + */ + public function setLastlogin($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->lastlogin !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->lastlogin !== null && $tmpDt = new DateTime($this->lastlogin)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->lastlogin = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcSubjsPeer::LASTLOGIN; + } + } // if either are not null + + return $this; + } // setLastlogin() + + /** + * Sets the value of [lastfail] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcSubjs The current object (for fluent API support) + */ + public function setLastfail($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->lastfail !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->lastfail !== null && $tmpDt = new DateTime($this->lastfail)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->lastfail = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcSubjsPeer::LASTFAIL; + } + } // if either are not null + + return $this; + } // setLastfail() + + /** + * 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() + { + if ($this->login !== '') { + return false; + } + + if ($this->pass !== '') { + return false; + } + + if ($this->type !== 'U') { + return false; + } + + if ($this->realname !== '') { + return false; + } + + // 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->login = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->pass = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->type = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->realname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->lastlogin = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->lastfail = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcSubjs 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() + { + + } // 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(CcSubjsPeer::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 = CcSubjsPeer::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->collCcAccesss = null; + + $this->collCcFiless = null; + + $this->collCcPermss = null; + + $this->collCcPlaylists = null; + + $this->collCcPrefs = null; + + $this->collCcSesss = 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(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcSubjsQuery::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(CcSubjsPeer::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); + CcSubjsPeer::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; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcSubjsPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collCcAccesss !== null) { + foreach ($this->collCcAccesss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collCcFiless !== null) { + foreach ($this->collCcFiless as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collCcPermss !== null) { + foreach ($this->collCcPermss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collCcPlaylists !== null) { + foreach ($this->collCcPlaylists as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collCcPrefs !== null) { + foreach ($this->collCcPrefs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collCcSesss !== null) { + foreach ($this->collCcSesss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcSubjsPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcAccesss !== null) { + foreach ($this->collCcAccesss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcFiless !== null) { + foreach ($this->collCcFiless as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPermss !== null) { + foreach ($this->collCcPermss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPlaylists !== null) { + foreach ($this->collCcPlaylists as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPrefs !== null) { + foreach ($this->collCcPrefs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcSesss !== null) { + foreach ($this->collCcSesss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $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 = CcSubjsPeer::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->getId(); + break; + case 1: + return $this->getLogin(); + break; + case 2: + return $this->getPass(); + break; + case 3: + return $this->getType(); + break; + case 4: + return $this->getRealname(); + break; + case 5: + return $this->getLastlogin(); + break; + case 6: + return $this->getLastfail(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcSubjsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLogin(), + $keys[2] => $this->getPass(), + $keys[3] => $this->getType(), + $keys[4] => $this->getRealname(), + $keys[5] => $this->getLastlogin(), + $keys[6] => $this->getLastfail(), + ); + 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 = CcSubjsPeer::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->setId($value); + break; + case 1: + $this->setLogin($value); + break; + case 2: + $this->setPass($value); + break; + case 3: + $this->setType($value); + break; + case 4: + $this->setRealname($value); + break; + case 5: + $this->setLastlogin($value); + break; + case 6: + $this->setLastfail($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 = CcSubjsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLogin($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPass($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setType($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setRealname($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setLastlogin($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLastfail($arr[$keys[6]]); + } + + /** + * 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(CcSubjsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcSubjsPeer::ID)) $criteria->add(CcSubjsPeer::ID, $this->id); + if ($this->isColumnModified(CcSubjsPeer::LOGIN)) $criteria->add(CcSubjsPeer::LOGIN, $this->login); + if ($this->isColumnModified(CcSubjsPeer::PASS)) $criteria->add(CcSubjsPeer::PASS, $this->pass); + if ($this->isColumnModified(CcSubjsPeer::TYPE)) $criteria->add(CcSubjsPeer::TYPE, $this->type); + if ($this->isColumnModified(CcSubjsPeer::REALNAME)) $criteria->add(CcSubjsPeer::REALNAME, $this->realname); + if ($this->isColumnModified(CcSubjsPeer::LASTLOGIN)) $criteria->add(CcSubjsPeer::LASTLOGIN, $this->lastlogin); + if ($this->isColumnModified(CcSubjsPeer::LASTFAIL)) $criteria->add(CcSubjsPeer::LASTFAIL, $this->lastfail); + + 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(CcSubjsPeer::DATABASE_NAME); + $criteria->add(CcSubjsPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcSubjs (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->setId($this->id); + $copyObj->setLogin($this->login); + $copyObj->setPass($this->pass); + $copyObj->setType($this->type); + $copyObj->setRealname($this->realname); + $copyObj->setLastlogin($this->lastlogin); + $copyObj->setLastfail($this->lastfail); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCcAccesss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcAccess($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcFiless() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcFiles($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcPermss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPerms($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcPlaylists() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlaylist($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcPrefs() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPref($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcSesss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcSess($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + + $copyObj->setNew(true); + } + + /** + * 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 CcSubjs 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 CcSubjsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcSubjsPeer(); + } + return self::$peer; + } + + /** + * Clears out the collCcAccesss 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 addCcAccesss() + */ + public function clearCcAccesss() + { + $this->collCcAccesss = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcAccesss collection. + * + * By default this just sets the collCcAccesss collection to an empty array (like clearcollCcAccesss()); + * 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 initCcAccesss() + { + $this->collCcAccesss = new PropelObjectCollection(); + $this->collCcAccesss->setModel('CcAccess'); + } + + /** + * Gets an array of CcAccess 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 CcSubjs 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 CcAccess[] List of CcAccess objects + * @throws PropelException + */ + public function getCcAccesss($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcAccesss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcAccesss) { + // return empty collection + $this->initCcAccesss(); + } else { + $collCcAccesss = CcAccessQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcAccesss; + } + $this->collCcAccesss = $collCcAccesss; + } + } + return $this->collCcAccesss; + } + + /** + * Returns the number of related CcAccess objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcAccess objects. + * @throws PropelException + */ + public function countCcAccesss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcAccesss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcAccesss) { + return 0; + } else { + $query = CcAccessQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcAccesss); + } + } + + /** + * Method called to associate a CcAccess object to this object + * through the CcAccess foreign key attribute. + * + * @param CcAccess $l CcAccess + * @return void + * @throws PropelException + */ + public function addCcAccess(CcAccess $l) + { + if ($this->collCcAccesss === null) { + $this->initCcAccesss(); + } + if (!$this->collCcAccesss->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcAccesss[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears out the collCcFiless 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 addCcFiless() + */ + public function clearCcFiless() + { + $this->collCcFiless = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcFiless collection. + * + * By default this just sets the collCcFiless collection to an empty array (like clearcollCcFiless()); + * 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 initCcFiless() + { + $this->collCcFiless = new PropelObjectCollection(); + $this->collCcFiless->setModel('CcFiles'); + } + + /** + * Gets an array of CcFiles 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 CcSubjs 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 CcFiles[] List of CcFiles objects + * @throws PropelException + */ + public function getCcFiless($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcFiless || null !== $criteria) { + if ($this->isNew() && null === $this->collCcFiless) { + // return empty collection + $this->initCcFiless(); + } else { + $collCcFiless = CcFilesQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcFiless; + } + $this->collCcFiless = $collCcFiless; + } + } + return $this->collCcFiless; + } + + /** + * Returns the number of related CcFiles objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcFiles objects. + * @throws PropelException + */ + public function countCcFiless(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcFiless || null !== $criteria) { + if ($this->isNew() && null === $this->collCcFiless) { + return 0; + } else { + $query = CcFilesQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcFiless); + } + } + + /** + * Method called to associate a CcFiles object to this object + * through the CcFiles foreign key attribute. + * + * @param CcFiles $l CcFiles + * @return void + * @throws PropelException + */ + public function addCcFiles(CcFiles $l) + { + if ($this->collCcFiless === null) { + $this->initCcFiless(); + } + if (!$this->collCcFiless->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcFiless[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears out the collCcPermss 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 addCcPermss() + */ + public function clearCcPermss() + { + $this->collCcPermss = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcPermss collection. + * + * By default this just sets the collCcPermss collection to an empty array (like clearcollCcPermss()); + * 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 initCcPermss() + { + $this->collCcPermss = new PropelObjectCollection(); + $this->collCcPermss->setModel('CcPerms'); + } + + /** + * Gets an array of CcPerms 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 CcSubjs 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 CcPerms[] List of CcPerms objects + * @throws PropelException + */ + public function getCcPermss($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcPermss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPermss) { + // return empty collection + $this->initCcPermss(); + } else { + $collCcPermss = CcPermsQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcPermss; + } + $this->collCcPermss = $collCcPermss; + } + } + return $this->collCcPermss; + } + + /** + * Returns the number of related CcPerms objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPerms objects. + * @throws PropelException + */ + public function countCcPermss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcPermss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPermss) { + return 0; + } else { + $query = CcPermsQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcPermss); + } + } + + /** + * Method called to associate a CcPerms object to this object + * through the CcPerms foreign key attribute. + * + * @param CcPerms $l CcPerms + * @return void + * @throws PropelException + */ + public function addCcPerms(CcPerms $l) + { + if ($this->collCcPermss === null) { + $this->initCcPermss(); + } + if (!$this->collCcPermss->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcPermss[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears out the collCcPlaylists 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 addCcPlaylists() + */ + public function clearCcPlaylists() + { + $this->collCcPlaylists = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcPlaylists collection. + * + * By default this just sets the collCcPlaylists collection to an empty array (like clearcollCcPlaylists()); + * 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 initCcPlaylists() + { + $this->collCcPlaylists = new PropelObjectCollection(); + $this->collCcPlaylists->setModel('CcPlaylist'); + } + + /** + * Gets an array of CcPlaylist 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 CcSubjs 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 CcPlaylist[] List of CcPlaylist objects + * @throws PropelException + */ + public function getCcPlaylists($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcPlaylists || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylists) { + // return empty collection + $this->initCcPlaylists(); + } else { + $collCcPlaylists = CcPlaylistQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcPlaylists; + } + $this->collCcPlaylists = $collCcPlaylists; + } + } + return $this->collCcPlaylists; + } + + /** + * Returns the number of related CcPlaylist objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlaylist objects. + * @throws PropelException + */ + public function countCcPlaylists(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcPlaylists || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPlaylists) { + return 0; + } else { + $query = CcPlaylistQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcPlaylists); + } + } + + /** + * Method called to associate a CcPlaylist object to this object + * through the CcPlaylist foreign key attribute. + * + * @param CcPlaylist $l CcPlaylist + * @return void + * @throws PropelException + */ + public function addCcPlaylist(CcPlaylist $l) + { + if ($this->collCcPlaylists === null) { + $this->initCcPlaylists(); + } + if (!$this->collCcPlaylists->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcPlaylists[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears out the collCcPrefs 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 addCcPrefs() + */ + public function clearCcPrefs() + { + $this->collCcPrefs = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcPrefs collection. + * + * By default this just sets the collCcPrefs collection to an empty array (like clearcollCcPrefs()); + * 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 initCcPrefs() + { + $this->collCcPrefs = new PropelObjectCollection(); + $this->collCcPrefs->setModel('CcPref'); + } + + /** + * Gets an array of CcPref 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 CcSubjs 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 CcPref[] List of CcPref objects + * @throws PropelException + */ + public function getCcPrefs($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcPrefs || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPrefs) { + // return empty collection + $this->initCcPrefs(); + } else { + $collCcPrefs = CcPrefQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcPrefs; + } + $this->collCcPrefs = $collCcPrefs; + } + } + return $this->collCcPrefs; + } + + /** + * Returns the number of related CcPref objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPref objects. + * @throws PropelException + */ + public function countCcPrefs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcPrefs || null !== $criteria) { + if ($this->isNew() && null === $this->collCcPrefs) { + return 0; + } else { + $query = CcPrefQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcPrefs); + } + } + + /** + * Method called to associate a CcPref object to this object + * through the CcPref foreign key attribute. + * + * @param CcPref $l CcPref + * @return void + * @throws PropelException + */ + public function addCcPref(CcPref $l) + { + if ($this->collCcPrefs === null) { + $this->initCcPrefs(); + } + if (!$this->collCcPrefs->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcPrefs[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears out the collCcSesss 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 addCcSesss() + */ + public function clearCcSesss() + { + $this->collCcSesss = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcSesss collection. + * + * By default this just sets the collCcSesss collection to an empty array (like clearcollCcSesss()); + * 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 initCcSesss() + { + $this->collCcSesss = new PropelObjectCollection(); + $this->collCcSesss->setModel('CcSess'); + } + + /** + * Gets an array of CcSess 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 CcSubjs 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 CcSess[] List of CcSess objects + * @throws PropelException + */ + public function getCcSesss($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcSesss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcSesss) { + // return empty collection + $this->initCcSesss(); + } else { + $collCcSesss = CcSessQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + return $collCcSesss; + } + $this->collCcSesss = $collCcSesss; + } + } + return $this->collCcSesss; + } + + /** + * Returns the number of related CcSess objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcSess objects. + * @throws PropelException + */ + public function countCcSesss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcSesss || null !== $criteria) { + if ($this->isNew() && null === $this->collCcSesss) { + return 0; + } else { + $query = CcSessQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcSubjs($this) + ->count($con); + } + } else { + return count($this->collCcSesss); + } + } + + /** + * Method called to associate a CcSess object to this object + * through the CcSess foreign key attribute. + * + * @param CcSess $l CcSess + * @return void + * @throws PropelException + */ + public function addCcSess(CcSess $l) + { + if ($this->collCcSesss === null) { + $this->initCcSesss(); + } + if (!$this->collCcSesss->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcSesss[]= $l; + $l->setCcSubjs($this); + } + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->login = null; + $this->pass = null; + $this->type = null; + $this->realname = null; + $this->lastlogin = null; + $this->lastfail = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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 ($this->collCcAccesss) { + foreach ((array) $this->collCcAccesss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcFiless) { + foreach ((array) $this->collCcFiless as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPermss) { + foreach ((array) $this->collCcPermss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPlaylists) { + foreach ((array) $this->collCcPlaylists as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPrefs) { + foreach ((array) $this->collCcPrefs as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcSesss) { + foreach ((array) $this->collCcSesss as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + $this->collCcAccesss = null; + $this->collCcFiless = null; + $this->collCcPermss = null; + $this->collCcPlaylists = null; + $this->collCcPrefs = null; + $this->collCcSesss = 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); + } + +} // BaseCcSubjs diff --git a/application/models/campcaster/om/BaseCcSubjsPeer.php b/application/models/campcaster/om/BaseCcSubjsPeer.php new file mode 100644 index 000000000..f4bc75f9f --- /dev/null +++ b/application/models/campcaster/om/BaseCcSubjsPeer.php @@ -0,0 +1,769 @@ + array ('Id', 'Login', 'Pass', 'Type', 'Realname', 'Lastlogin', 'Lastfail', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'login', 'pass', 'type', 'realname', 'lastlogin', 'lastfail', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::LOGIN, self::PASS, self::TYPE, self::REALNAME, self::LASTLOGIN, self::LASTFAIL, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'REALNAME', 'LASTLOGIN', 'LASTFAIL', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'realname', 'lastlogin', 'lastfail', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * 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 ('Id' => 0, 'Login' => 1, 'Pass' => 2, 'Type' => 3, 'Realname' => 4, 'Lastlogin' => 5, 'Lastfail' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'realname' => 4, 'lastlogin' => 5, 'lastfail' => 6, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOGIN => 1, self::PASS => 2, self::TYPE => 3, self::REALNAME => 4, self::LASTLOGIN => 5, self::LASTFAIL => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'REALNAME' => 4, 'LASTLOGIN' => 5, 'LASTFAIL' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'realname' => 4, 'lastlogin' => 5, 'lastfail' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * 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. CcSubjsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcSubjsPeer::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(CcSubjsPeer::ID); + $criteria->addSelectColumn(CcSubjsPeer::LOGIN); + $criteria->addSelectColumn(CcSubjsPeer::PASS); + $criteria->addSelectColumn(CcSubjsPeer::TYPE); + $criteria->addSelectColumn(CcSubjsPeer::REALNAME); + $criteria->addSelectColumn(CcSubjsPeer::LASTLOGIN); + $criteria->addSelectColumn(CcSubjsPeer::LASTFAIL); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOGIN'); + $criteria->addSelectColumn($alias . '.PASS'); + $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.REALNAME'); + $criteria->addSelectColumn($alias . '.LASTLOGIN'); + $criteria->addSelectColumn($alias . '.LASTFAIL'); + } + } + + /** + * 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(CcSubjsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSubjsPeer::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(CcSubjsPeer::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 CcSubjs + * @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 = CcSubjsPeer::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 CcSubjsPeer::populateObjects(CcSubjsPeer::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(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcSubjsPeer::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 CcSubjs $value A CcSubjs object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcSubjs $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcSubjs object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSubjs) { + $key = (string) $value->getId(); + } 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 CcSubjs 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 CcSubjs 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_subjs + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcPermsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPermsPeer::clearInstancePool(); + // Invalidate objects in CcPrefPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPrefPeer::clearInstancePool(); + // Invalidate objects in CcSessPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcSessPeer::clearInstancePool(); + } + + /** + * 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 = CcSubjsPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcSubjsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcSubjsPeer::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; + CcSubjsPeer::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 (CcSubjs object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcSubjsPeer::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 + CcSubjsPeer::NUM_COLUMNS; + } else { + $cls = CcSubjsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcSubjsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcSubjsPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcSubjsTableMap()); + } + } + + /** + * 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 ? CcSubjsPeer::CLASS_DEFAULT : CcSubjsPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcSubjs or Criteria object. + * + * @param mixed $values Criteria or CcSubjs 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(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcSubjs object + } + + + // 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 CcSubjs or Criteria object. + * + * @param mixed $values Criteria or CcSubjs 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(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcSubjsPeer::ID); + $value = $criteria->remove(CcSubjsPeer::ID); + if ($value) { + $selectCriteria->add(CcSubjsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcSubjsPeer::TABLE_NAME); + } + + } else { // $values is CcSubjs 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_subjs 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(CcSubjsPeer::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(CcSubjsPeer::TABLE_NAME, $con, CcSubjsPeer::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). + CcSubjsPeer::clearInstancePool(); + CcSubjsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcSubjs or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcSubjs 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(CcSubjsPeer::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. + CcSubjsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcSubjs) { // it's a model object + // invalidate the cache for this single object + CcSubjsPeer::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(CcSubjsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcSubjsPeer::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); + CcSubjsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcSubjs 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 CcSubjs $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(CcSubjs $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcSubjsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcSubjsPeer::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(CcSubjsPeer::DATABASE_NAME, CcSubjsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcSubjs + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcSubjsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcSubjsPeer::DATABASE_NAME); + $criteria->add(CcSubjsPeer::ID, $pk); + + $v = CcSubjsPeer::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(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcSubjsPeer::DATABASE_NAME); + $criteria->add(CcSubjsPeer::ID, $pks, Criteria::IN); + $objs = CcSubjsPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcSubjsPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcSubjsPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcSubjsQuery.php b/application/models/campcaster/om/BaseCcSubjsQuery.php new file mode 100644 index 000000000..af3b6fe5e --- /dev/null +++ b/application/models/campcaster/om/BaseCcSubjsQuery.php @@ -0,0 +1,747 @@ +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 CcSubjs|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcSubjsPeer::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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcSubjsPeer::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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcSubjsPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $id 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcSubjsPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the login column + * + * @param string $login 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByLogin($login = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($login)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $login)) { + $login = str_replace('*', '%', $login); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSubjsPeer::LOGIN, $login, $comparison); + } + + /** + * Filter the query on the pass column + * + * @param string $pass 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByPass($pass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($pass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $pass)) { + $pass = str_replace('*', '%', $pass); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSubjsPeer::PASS, $pass, $comparison); + } + + /** + * Filter the query on the type column + * + * @param string $type 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByType($type = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($type)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $type)) { + $type = str_replace('*', '%', $type); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSubjsPeer::TYPE, $type, $comparison); + } + + /** + * Filter the query on the realname column + * + * @param string $realname 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByRealname($realname = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($realname)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $realname)) { + $realname = str_replace('*', '%', $realname); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcSubjsPeer::REALNAME, $realname, $comparison); + } + + /** + * Filter the query on the lastlogin column + * + * @param string|array $lastlogin 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByLastlogin($lastlogin = null, $comparison = null) + { + if (is_array($lastlogin)) { + $useMinMax = false; + if (isset($lastlogin['min'])) { + $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $lastlogin['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastlogin['max'])) { + $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $lastlogin['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $lastlogin, $comparison); + } + + /** + * Filter the query on the lastfail column + * + * @param string|array $lastfail 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByLastfail($lastfail = null, $comparison = null) + { + if (is_array($lastfail)) { + $useMinMax = false; + if (isset($lastfail['min'])) { + $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $lastfail['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastfail['max'])) { + $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $lastfail['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $lastfail, $comparison); + } + + /** + * Filter the query by a related CcAccess object + * + * @param CcAccess $ccAccess the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcAccess($ccAccess, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccAccess->getOwner(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcAccess relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function joinCcAccess($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcAccess'); + + // 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, 'CcAccess'); + } + + return $this; + } + + /** + * Use the CcAccess relation CcAccess 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 CcAccessQuery A secondary query class using the current class as primary query + */ + public function useCcAccessQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcAccess($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcAccess', 'CcAccessQuery'); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles $ccFiles the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccFiles->getEditedby(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcFiles relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcFiles'); + + // 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, 'CcFiles'); + } + + return $this; + } + + /** + * Use the CcFiles relation CcFiles 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 CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery'); + } + + /** + * Filter the query by a related CcPerms object + * + * @param CcPerms $ccPerms the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcPerms($ccPerms, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccPerms->getSubj(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcPerms relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function joinCcPerms($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPerms'); + + // 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, 'CcPerms'); + } + + return $this; + } + + /** + * Use the CcPerms relation CcPerms 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 CcPermsQuery A secondary query class using the current class as primary query + */ + public function useCcPermsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPerms($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPerms', 'CcPermsQuery'); + } + + /** + * 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 CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcPlaylist($ccPlaylist, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccPlaylist->getDbEditedby(), $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 CcSubjsQuery The current query, for fluid interface + */ + public function joinCcPlaylist($relationAlias = '', $joinType = Criteria::LEFT_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::LEFT_JOIN) + { + return $this + ->joinCcPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', 'CcPlaylistQuery'); + } + + /** + * Filter the query by a related CcPref object + * + * @param CcPref $ccPref the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcPref($ccPref, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccPref->getSubjid(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcPref relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function joinCcPref($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPref'); + + // 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, 'CcPref'); + } + + return $this; + } + + /** + * Use the CcPref relation CcPref 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 CcPrefQuery A secondary query class using the current class as primary query + */ + public function useCcPrefQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPref($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPref', 'CcPrefQuery'); + } + + /** + * Filter the query by a related CcSess object + * + * @param CcSess $ccSess the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByCcSess($ccSess, $comparison = null) + { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccSess->getUserid(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcSess relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function joinCcSess($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSess'); + + // 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, 'CcSess'); + } + + return $this; + } + + /** + * Use the CcSess relation CcSess 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 CcSessQuery A secondary query class using the current class as primary query + */ + public function useCcSessQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSess($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSess', 'CcSessQuery'); + } + + /** + * Exclude object from result + * + * @param CcSubjs $ccSubjs Object to remove from the list of results + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function prune($ccSubjs = null) + { + if ($ccSubjs) { + $this->addUsingAlias(CcSubjsPeer::ID, $ccSubjs->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcSubjsQuery diff --git a/application/models/campcaster/om/BaseCcTrans.php b/application/models/campcaster/om/BaseCcTrans.php new file mode 100644 index 000000000..e7ce7ef9f --- /dev/null +++ b/application/models/campcaster/om/BaseCcTrans.php @@ -0,0 +1,1903 @@ +lock = 'N'; + } + + /** + * Initializes internal state of BaseCcTrans object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Get the [trtok] column value. + * + * @return string + */ + public function getTrtok() + { + return $this->trtok; + } + + /** + * Get the [direction] column value. + * + * @return string + */ + public function getDirection() + { + return $this->direction; + } + + /** + * Get the [state] column value. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Get the [trtype] column value. + * + * @return string + */ + public function getTrtype() + { + return $this->trtype; + } + + /** + * Get the [lock] column value. + * + * @return string + */ + public function getLock() + { + return $this->lock; + } + + /** + * Get the [target] column value. + * + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Get the [rtrtok] column value. + * + * @return string + */ + public function getRtrtok() + { + return $this->rtrtok; + } + + /** + * Get the [mdtrtok] column value. + * + * @return string + */ + public function getMdtrtok() + { + return $this->mdtrtok; + } + + /** + * Get the [gunid] column value. + * + * @return string + */ + public function getGunid() + { + return $this->gunid; + } + + /** + * Get the [pdtoken] column value. + * + * @return string + */ + public function getPdtoken() + { + return $this->pdtoken; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Get the [localfile] column value. + * + * @return string + */ + public function getLocalfile() + { + return $this->localfile; + } + + /** + * Get the [fname] column value. + * + * @return string + */ + public function getFname() + { + return $this->fname; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Get the [expectedsum] column value. + * + * @return string + */ + public function getExpectedsum() + { + return $this->expectedsum; + } + + /** + * Get the [realsum] column value. + * + * @return string + */ + public function getRealsum() + { + return $this->realsum; + } + + /** + * Get the [expectedsize] column value. + * + * @return int + */ + public function getExpectedsize() + { + return $this->expectedsize; + } + + /** + * Get the [realsize] column value. + * + * @return int + */ + public function getRealsize() + { + return $this->realsize; + } + + /** + * Get the [uid] column value. + * + * @return int + */ + public function getUid() + { + return $this->uid; + } + + /** + * Get the [errmsg] column value. + * + * @return string + */ + public function getErrmsg() + { + return $this->errmsg; + } + + /** + * Get the [jobpid] column value. + * + * @return int + */ + public function getJobpid() + { + return $this->jobpid; + } + + /** + * Get the [optionally formatted] temporal [start] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getStart($format = 'Y-m-d H:i:s') + { + if ($this->start === null) { + return null; + } + + + + try { + $dt = new DateTime($this->start); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->start, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [optionally formatted] temporal [ts] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getTs($format = 'Y-m-d H:i:s') + { + if ($this->ts === null) { + return null; + } + + + + try { + $dt = new DateTime($this->ts); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ts, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcTransPeer::ID; + } + + return $this; + } // setId() + + /** + * Set the value of [trtok] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setTrtok($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->trtok !== $v) { + $this->trtok = $v; + $this->modifiedColumns[] = CcTransPeer::TRTOK; + } + + return $this; + } // setTrtok() + + /** + * Set the value of [direction] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setDirection($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->direction !== $v) { + $this->direction = $v; + $this->modifiedColumns[] = CcTransPeer::DIRECTION; + } + + return $this; + } // setDirection() + + /** + * Set the value of [state] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setState($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->state !== $v) { + $this->state = $v; + $this->modifiedColumns[] = CcTransPeer::STATE; + } + + return $this; + } // setState() + + /** + * Set the value of [trtype] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setTrtype($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->trtype !== $v) { + $this->trtype = $v; + $this->modifiedColumns[] = CcTransPeer::TRTYPE; + } + + return $this; + } // setTrtype() + + /** + * Set the value of [lock] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setLock($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->lock !== $v || $this->isNew()) { + $this->lock = $v; + $this->modifiedColumns[] = CcTransPeer::LOCK; + } + + return $this; + } // setLock() + + /** + * Set the value of [target] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setTarget($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->target !== $v) { + $this->target = $v; + $this->modifiedColumns[] = CcTransPeer::TARGET; + } + + return $this; + } // setTarget() + + /** + * Set the value of [rtrtok] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setRtrtok($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->rtrtok !== $v) { + $this->rtrtok = $v; + $this->modifiedColumns[] = CcTransPeer::RTRTOK; + } + + return $this; + } // setRtrtok() + + /** + * Set the value of [mdtrtok] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setMdtrtok($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->mdtrtok !== $v) { + $this->mdtrtok = $v; + $this->modifiedColumns[] = CcTransPeer::MDTRTOK; + } + + return $this; + } // setMdtrtok() + + /** + * Set the value of [gunid] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setGunid($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->gunid !== $v) { + $this->gunid = $v; + $this->modifiedColumns[] = CcTransPeer::GUNID; + } + + return $this; + } // setGunid() + + /** + * Set the value of [pdtoken] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setPdtoken($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->pdtoken !== $v) { + $this->pdtoken = $v; + $this->modifiedColumns[] = CcTransPeer::PDTOKEN; + } + + return $this; + } // setPdtoken() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = CcTransPeer::URL; + } + + return $this; + } // setUrl() + + /** + * Set the value of [localfile] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setLocalfile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->localfile !== $v) { + $this->localfile = $v; + $this->modifiedColumns[] = CcTransPeer::LOCALFILE; + } + + return $this; + } // setLocalfile() + + /** + * Set the value of [fname] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setFname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->fname !== $v) { + $this->fname = $v; + $this->modifiedColumns[] = CcTransPeer::FNAME; + } + + return $this; + } // setFname() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CcTransPeer::TITLE; + } + + return $this; + } // setTitle() + + /** + * Set the value of [expectedsum] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setExpectedsum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->expectedsum !== $v) { + $this->expectedsum = $v; + $this->modifiedColumns[] = CcTransPeer::EXPECTEDSUM; + } + + return $this; + } // setExpectedsum() + + /** + * Set the value of [realsum] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setRealsum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->realsum !== $v) { + $this->realsum = $v; + $this->modifiedColumns[] = CcTransPeer::REALSUM; + } + + return $this; + } // setRealsum() + + /** + * Set the value of [expectedsize] column. + * + * @param int $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setExpectedsize($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->expectedsize !== $v) { + $this->expectedsize = $v; + $this->modifiedColumns[] = CcTransPeer::EXPECTEDSIZE; + } + + return $this; + } // setExpectedsize() + + /** + * Set the value of [realsize] column. + * + * @param int $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setRealsize($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->realsize !== $v) { + $this->realsize = $v; + $this->modifiedColumns[] = CcTransPeer::REALSIZE; + } + + return $this; + } // setRealsize() + + /** + * Set the value of [uid] column. + * + * @param int $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setUid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->uid !== $v) { + $this->uid = $v; + $this->modifiedColumns[] = CcTransPeer::UID; + } + + return $this; + } // setUid() + + /** + * Set the value of [errmsg] column. + * + * @param string $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setErrmsg($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->errmsg !== $v) { + $this->errmsg = $v; + $this->modifiedColumns[] = CcTransPeer::ERRMSG; + } + + return $this; + } // setErrmsg() + + /** + * Set the value of [jobpid] column. + * + * @param int $v new value + * @return CcTrans The current object (for fluent API support) + */ + public function setJobpid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->jobpid !== $v) { + $this->jobpid = $v; + $this->modifiedColumns[] = CcTransPeer::JOBPID; + } + + return $this; + } // setJobpid() + + /** + * Sets the value of [start] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcTrans The current object (for fluent API support) + */ + public function setStart($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->start !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->start !== null && $tmpDt = new DateTime($this->start)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->start = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcTransPeer::START; + } + } // if either are not null + + return $this; + } // setStart() + + /** + * Sets the value of [ts] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcTrans The current object (for fluent API support) + */ + public function setTs($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->ts !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->ts !== null && $tmpDt = new DateTime($this->ts)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null; + $newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->ts = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); + $this->modifiedColumns[] = CcTransPeer::TS; + } + } // if either are not null + + return $this; + } // setTs() + + /** + * 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() + { + if ($this->lock !== 'N') { + return false; + } + + // 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->trtok = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->direction = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->state = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->trtype = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->lock = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->target = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->rtrtok = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->mdtrtok = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->gunid = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->pdtoken = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->url = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->localfile = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; + $this->fname = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; + $this->title = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; + $this->expectedsum = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; + $this->realsum = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; + $this->expectedsize = ($row[$startcol + 17] !== null) ? (int) $row[$startcol + 17] : null; + $this->realsize = ($row[$startcol + 18] !== null) ? (int) $row[$startcol + 18] : null; + $this->uid = ($row[$startcol + 19] !== null) ? (int) $row[$startcol + 19] : null; + $this->errmsg = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; + $this->jobpid = ($row[$startcol + 21] !== null) ? (int) $row[$startcol + 21] : null; + $this->start = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null; + $this->ts = ($row[$startcol + 23] !== null) ? (string) $row[$startcol + 23] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 24; // 24 = CcTransPeer::NUM_COLUMNS - CcTransPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcTrans 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() + { + + } // 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(CcTransPeer::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 = CcTransPeer::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? + + } // 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(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcTransQuery::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(CcTransPeer::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); + CcTransPeer::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; + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcTransPeer::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(CcTransPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTransPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows = CcTransPeer::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 thentrue
is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixedtrue
if all validations pass; array ofValidationFailed
objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcTransPeer::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 = CcTransPeer::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->getId(); + break; + case 1: + return $this->getTrtok(); + break; + case 2: + return $this->getDirection(); + break; + case 3: + return $this->getState(); + break; + case 4: + return $this->getTrtype(); + break; + case 5: + return $this->getLock(); + break; + case 6: + return $this->getTarget(); + break; + case 7: + return $this->getRtrtok(); + break; + case 8: + return $this->getMdtrtok(); + break; + case 9: + return $this->getGunid(); + break; + case 10: + return $this->getPdtoken(); + break; + case 11: + return $this->getUrl(); + break; + case 12: + return $this->getLocalfile(); + break; + case 13: + return $this->getFname(); + break; + case 14: + return $this->getTitle(); + break; + case 15: + return $this->getExpectedsum(); + break; + case 16: + return $this->getRealsum(); + break; + case 17: + return $this->getExpectedsize(); + break; + case 18: + return $this->getRealsize(); + break; + case 19: + return $this->getUid(); + break; + case 20: + return $this->getErrmsg(); + break; + case 21: + return $this->getJobpid(); + break; + case 22: + return $this->getStart(); + break; + case 23: + return $this->getTs(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcTransPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getTrtok(), + $keys[2] => $this->getDirection(), + $keys[3] => $this->getState(), + $keys[4] => $this->getTrtype(), + $keys[5] => $this->getLock(), + $keys[6] => $this->getTarget(), + $keys[7] => $this->getRtrtok(), + $keys[8] => $this->getMdtrtok(), + $keys[9] => $this->getGunid(), + $keys[10] => $this->getPdtoken(), + $keys[11] => $this->getUrl(), + $keys[12] => $this->getLocalfile(), + $keys[13] => $this->getFname(), + $keys[14] => $this->getTitle(), + $keys[15] => $this->getExpectedsum(), + $keys[16] => $this->getRealsum(), + $keys[17] => $this->getExpectedsize(), + $keys[18] => $this->getRealsize(), + $keys[19] => $this->getUid(), + $keys[20] => $this->getErrmsg(), + $keys[21] => $this->getJobpid(), + $keys[22] => $this->getStart(), + $keys[23] => $this->getTs(), + ); + 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 = CcTransPeer::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->setId($value); + break; + case 1: + $this->setTrtok($value); + break; + case 2: + $this->setDirection($value); + break; + case 3: + $this->setState($value); + break; + case 4: + $this->setTrtype($value); + break; + case 5: + $this->setLock($value); + break; + case 6: + $this->setTarget($value); + break; + case 7: + $this->setRtrtok($value); + break; + case 8: + $this->setMdtrtok($value); + break; + case 9: + $this->setGunid($value); + break; + case 10: + $this->setPdtoken($value); + break; + case 11: + $this->setUrl($value); + break; + case 12: + $this->setLocalfile($value); + break; + case 13: + $this->setFname($value); + break; + case 14: + $this->setTitle($value); + break; + case 15: + $this->setExpectedsum($value); + break; + case 16: + $this->setRealsum($value); + break; + case 17: + $this->setExpectedsize($value); + break; + case 18: + $this->setRealsize($value); + break; + case 19: + $this->setUid($value); + break; + case 20: + $this->setErrmsg($value); + break; + case 21: + $this->setJobpid($value); + break; + case 22: + $this->setStart($value); + break; + case 23: + $this->setTs($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 = CcTransPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setTrtok($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDirection($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setState($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTrtype($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setLock($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setTarget($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setRtrtok($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMdtrtok($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setGunid($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setPdtoken($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setUrl($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setLocalfile($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setFname($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setTitle($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setExpectedsum($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setRealsum($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setExpectedsize($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setRealsize($arr[$keys[18]]); + if (array_key_exists($keys[19], $arr)) $this->setUid($arr[$keys[19]]); + if (array_key_exists($keys[20], $arr)) $this->setErrmsg($arr[$keys[20]]); + if (array_key_exists($keys[21], $arr)) $this->setJobpid($arr[$keys[21]]); + if (array_key_exists($keys[22], $arr)) $this->setStart($arr[$keys[22]]); + if (array_key_exists($keys[23], $arr)) $this->setTs($arr[$keys[23]]); + } + + /** + * 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(CcTransPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcTransPeer::ID)) $criteria->add(CcTransPeer::ID, $this->id); + if ($this->isColumnModified(CcTransPeer::TRTOK)) $criteria->add(CcTransPeer::TRTOK, $this->trtok); + if ($this->isColumnModified(CcTransPeer::DIRECTION)) $criteria->add(CcTransPeer::DIRECTION, $this->direction); + if ($this->isColumnModified(CcTransPeer::STATE)) $criteria->add(CcTransPeer::STATE, $this->state); + if ($this->isColumnModified(CcTransPeer::TRTYPE)) $criteria->add(CcTransPeer::TRTYPE, $this->trtype); + if ($this->isColumnModified(CcTransPeer::LOCK)) $criteria->add(CcTransPeer::LOCK, $this->lock); + if ($this->isColumnModified(CcTransPeer::TARGET)) $criteria->add(CcTransPeer::TARGET, $this->target); + if ($this->isColumnModified(CcTransPeer::RTRTOK)) $criteria->add(CcTransPeer::RTRTOK, $this->rtrtok); + if ($this->isColumnModified(CcTransPeer::MDTRTOK)) $criteria->add(CcTransPeer::MDTRTOK, $this->mdtrtok); + if ($this->isColumnModified(CcTransPeer::GUNID)) $criteria->add(CcTransPeer::GUNID, $this->gunid); + if ($this->isColumnModified(CcTransPeer::PDTOKEN)) $criteria->add(CcTransPeer::PDTOKEN, $this->pdtoken); + if ($this->isColumnModified(CcTransPeer::URL)) $criteria->add(CcTransPeer::URL, $this->url); + if ($this->isColumnModified(CcTransPeer::LOCALFILE)) $criteria->add(CcTransPeer::LOCALFILE, $this->localfile); + if ($this->isColumnModified(CcTransPeer::FNAME)) $criteria->add(CcTransPeer::FNAME, $this->fname); + if ($this->isColumnModified(CcTransPeer::TITLE)) $criteria->add(CcTransPeer::TITLE, $this->title); + if ($this->isColumnModified(CcTransPeer::EXPECTEDSUM)) $criteria->add(CcTransPeer::EXPECTEDSUM, $this->expectedsum); + if ($this->isColumnModified(CcTransPeer::REALSUM)) $criteria->add(CcTransPeer::REALSUM, $this->realsum); + if ($this->isColumnModified(CcTransPeer::EXPECTEDSIZE)) $criteria->add(CcTransPeer::EXPECTEDSIZE, $this->expectedsize); + if ($this->isColumnModified(CcTransPeer::REALSIZE)) $criteria->add(CcTransPeer::REALSIZE, $this->realsize); + if ($this->isColumnModified(CcTransPeer::UID)) $criteria->add(CcTransPeer::UID, $this->uid); + if ($this->isColumnModified(CcTransPeer::ERRMSG)) $criteria->add(CcTransPeer::ERRMSG, $this->errmsg); + if ($this->isColumnModified(CcTransPeer::JOBPID)) $criteria->add(CcTransPeer::JOBPID, $this->jobpid); + if ($this->isColumnModified(CcTransPeer::START)) $criteria->add(CcTransPeer::START, $this->start); + if ($this->isColumnModified(CcTransPeer::TS)) $criteria->add(CcTransPeer::TS, $this->ts); + + 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(CcTransPeer::DATABASE_NAME); + $criteria->add(CcTransPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getId(); + } + + /** + * 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 CcTrans (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->setTrtok($this->trtok); + $copyObj->setDirection($this->direction); + $copyObj->setState($this->state); + $copyObj->setTrtype($this->trtype); + $copyObj->setLock($this->lock); + $copyObj->setTarget($this->target); + $copyObj->setRtrtok($this->rtrtok); + $copyObj->setMdtrtok($this->mdtrtok); + $copyObj->setGunid($this->gunid); + $copyObj->setPdtoken($this->pdtoken); + $copyObj->setUrl($this->url); + $copyObj->setLocalfile($this->localfile); + $copyObj->setFname($this->fname); + $copyObj->setTitle($this->title); + $copyObj->setExpectedsum($this->expectedsum); + $copyObj->setRealsum($this->realsum); + $copyObj->setExpectedsize($this->expectedsize); + $copyObj->setRealsize($this->realsize); + $copyObj->setUid($this->uid); + $copyObj->setErrmsg($this->errmsg); + $copyObj->setJobpid($this->jobpid); + $copyObj->setStart($this->start); + $copyObj->setTs($this->ts); + + $copyObj->setNew(true); + $copyObj->setId(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 CcTrans 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 CcTransPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcTransPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->trtok = null; + $this->direction = null; + $this->state = null; + $this->trtype = null; + $this->lock = null; + $this->target = null; + $this->rtrtok = null; + $this->mdtrtok = null; + $this->gunid = null; + $this->pdtoken = null; + $this->url = null; + $this->localfile = null; + $this->fname = null; + $this->title = null; + $this->expectedsum = null; + $this->realsum = null; + $this->expectedsize = null; + $this->realsize = null; + $this->uid = null; + $this->errmsg = null; + $this->jobpid = null; + $this->start = null; + $this->ts = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $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) + + } + + /** + * 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); + } + +} // BaseCcTrans diff --git a/application/models/campcaster/om/BaseCcTransPeer.php b/application/models/campcaster/om/BaseCcTransPeer.php new file mode 100644 index 000000000..c8dd333a9 --- /dev/null +++ b/application/models/campcaster/om/BaseCcTransPeer.php @@ -0,0 +1,849 @@ + array ('Id', 'Trtok', 'Direction', 'State', 'Trtype', 'Lock', 'Target', 'Rtrtok', 'Mdtrtok', 'Gunid', 'Pdtoken', 'Url', 'Localfile', 'Fname', 'Title', 'Expectedsum', 'Realsum', 'Expectedsize', 'Realsize', 'Uid', 'Errmsg', 'Jobpid', 'Start', 'Ts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'trtok', 'direction', 'state', 'trtype', 'lock', 'target', 'rtrtok', 'mdtrtok', 'gunid', 'pdtoken', 'url', 'localfile', 'fname', 'title', 'expectedsum', 'realsum', 'expectedsize', 'realsize', 'uid', 'errmsg', 'jobpid', 'start', 'ts', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::TRTOK, self::DIRECTION, self::STATE, self::TRTYPE, self::LOCK, self::TARGET, self::RTRTOK, self::MDTRTOK, self::GUNID, self::PDTOKEN, self::URL, self::LOCALFILE, self::FNAME, self::TITLE, self::EXPECTEDSUM, self::REALSUM, self::EXPECTEDSIZE, self::REALSIZE, self::UID, self::ERRMSG, self::JOBPID, self::START, self::TS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TRTOK', 'DIRECTION', 'STATE', 'TRTYPE', 'LOCK', 'TARGET', 'RTRTOK', 'MDTRTOK', 'GUNID', 'PDTOKEN', 'URL', 'LOCALFILE', 'FNAME', 'TITLE', 'EXPECTEDSUM', 'REALSUM', 'EXPECTEDSIZE', 'REALSIZE', 'UID', 'ERRMSG', 'JOBPID', 'START', 'TS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'trtok', 'direction', 'state', 'trtype', 'lock', 'target', 'rtrtok', 'mdtrtok', 'gunid', 'pdtoken', 'url', 'localfile', 'fname', 'title', 'expectedsum', 'realsum', 'expectedsize', 'realsize', 'uid', 'errmsg', 'jobpid', 'start', 'ts', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + ); + + /** + * 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 ('Id' => 0, 'Trtok' => 1, 'Direction' => 2, 'State' => 3, 'Trtype' => 4, 'Lock' => 5, 'Target' => 6, 'Rtrtok' => 7, 'Mdtrtok' => 8, 'Gunid' => 9, 'Pdtoken' => 10, 'Url' => 11, 'Localfile' => 12, 'Fname' => 13, 'Title' => 14, 'Expectedsum' => 15, 'Realsum' => 16, 'Expectedsize' => 17, 'Realsize' => 18, 'Uid' => 19, 'Errmsg' => 20, 'Jobpid' => 21, 'Start' => 22, 'Ts' => 23, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'trtok' => 1, 'direction' => 2, 'state' => 3, 'trtype' => 4, 'lock' => 5, 'target' => 6, 'rtrtok' => 7, 'mdtrtok' => 8, 'gunid' => 9, 'pdtoken' => 10, 'url' => 11, 'localfile' => 12, 'fname' => 13, 'title' => 14, 'expectedsum' => 15, 'realsum' => 16, 'expectedsize' => 17, 'realsize' => 18, 'uid' => 19, 'errmsg' => 20, 'jobpid' => 21, 'start' => 22, 'ts' => 23, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TRTOK => 1, self::DIRECTION => 2, self::STATE => 3, self::TRTYPE => 4, self::LOCK => 5, self::TARGET => 6, self::RTRTOK => 7, self::MDTRTOK => 8, self::GUNID => 9, self::PDTOKEN => 10, self::URL => 11, self::LOCALFILE => 12, self::FNAME => 13, self::TITLE => 14, self::EXPECTEDSUM => 15, self::REALSUM => 16, self::EXPECTEDSIZE => 17, self::REALSIZE => 18, self::UID => 19, self::ERRMSG => 20, self::JOBPID => 21, self::START => 22, self::TS => 23, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TRTOK' => 1, 'DIRECTION' => 2, 'STATE' => 3, 'TRTYPE' => 4, 'LOCK' => 5, 'TARGET' => 6, 'RTRTOK' => 7, 'MDTRTOK' => 8, 'GUNID' => 9, 'PDTOKEN' => 10, 'URL' => 11, 'LOCALFILE' => 12, 'FNAME' => 13, 'TITLE' => 14, 'EXPECTEDSUM' => 15, 'REALSUM' => 16, 'EXPECTEDSIZE' => 17, 'REALSIZE' => 18, 'UID' => 19, 'ERRMSG' => 20, 'JOBPID' => 21, 'START' => 22, 'TS' => 23, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'trtok' => 1, 'direction' => 2, 'state' => 3, 'trtype' => 4, 'lock' => 5, 'target' => 6, 'rtrtok' => 7, 'mdtrtok' => 8, 'gunid' => 9, 'pdtoken' => 10, 'url' => 11, 'localfile' => 12, 'fname' => 13, 'title' => 14, 'expectedsum' => 15, 'realsum' => 16, 'expectedsize' => 17, 'realsize' => 18, 'uid' => 19, 'errmsg' => 20, 'jobpid' => 21, 'start' => 22, 'ts' => 23, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + ); + + /** + * 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. CcTransPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcTransPeer::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(CcTransPeer::ID); + $criteria->addSelectColumn(CcTransPeer::TRTOK); + $criteria->addSelectColumn(CcTransPeer::DIRECTION); + $criteria->addSelectColumn(CcTransPeer::STATE); + $criteria->addSelectColumn(CcTransPeer::TRTYPE); + $criteria->addSelectColumn(CcTransPeer::LOCK); + $criteria->addSelectColumn(CcTransPeer::TARGET); + $criteria->addSelectColumn(CcTransPeer::RTRTOK); + $criteria->addSelectColumn(CcTransPeer::MDTRTOK); + $criteria->addSelectColumn(CcTransPeer::GUNID); + $criteria->addSelectColumn(CcTransPeer::PDTOKEN); + $criteria->addSelectColumn(CcTransPeer::URL); + $criteria->addSelectColumn(CcTransPeer::LOCALFILE); + $criteria->addSelectColumn(CcTransPeer::FNAME); + $criteria->addSelectColumn(CcTransPeer::TITLE); + $criteria->addSelectColumn(CcTransPeer::EXPECTEDSUM); + $criteria->addSelectColumn(CcTransPeer::REALSUM); + $criteria->addSelectColumn(CcTransPeer::EXPECTEDSIZE); + $criteria->addSelectColumn(CcTransPeer::REALSIZE); + $criteria->addSelectColumn(CcTransPeer::UID); + $criteria->addSelectColumn(CcTransPeer::ERRMSG); + $criteria->addSelectColumn(CcTransPeer::JOBPID); + $criteria->addSelectColumn(CcTransPeer::START); + $criteria->addSelectColumn(CcTransPeer::TS); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.TRTOK'); + $criteria->addSelectColumn($alias . '.DIRECTION'); + $criteria->addSelectColumn($alias . '.STATE'); + $criteria->addSelectColumn($alias . '.TRTYPE'); + $criteria->addSelectColumn($alias . '.LOCK'); + $criteria->addSelectColumn($alias . '.TARGET'); + $criteria->addSelectColumn($alias . '.RTRTOK'); + $criteria->addSelectColumn($alias . '.MDTRTOK'); + $criteria->addSelectColumn($alias . '.GUNID'); + $criteria->addSelectColumn($alias . '.PDTOKEN'); + $criteria->addSelectColumn($alias . '.URL'); + $criteria->addSelectColumn($alias . '.LOCALFILE'); + $criteria->addSelectColumn($alias . '.FNAME'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.EXPECTEDSUM'); + $criteria->addSelectColumn($alias . '.REALSUM'); + $criteria->addSelectColumn($alias . '.EXPECTEDSIZE'); + $criteria->addSelectColumn($alias . '.REALSIZE'); + $criteria->addSelectColumn($alias . '.UID'); + $criteria->addSelectColumn($alias . '.ERRMSG'); + $criteria->addSelectColumn($alias . '.JOBPID'); + $criteria->addSelectColumn($alias . '.START'); + $criteria->addSelectColumn($alias . '.TS'); + } + } + + /** + * 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(CcTransPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcTransPeer::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(CcTransPeer::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 CcTrans + * @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 = CcTransPeer::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 CcTransPeer::populateObjects(CcTransPeer::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(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcTransPeer::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 CcTrans $value A CcTrans object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcTrans $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // 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 CcTrans object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcTrans) { + $key = (string) $value->getId(); + } 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 CcTrans 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 CcTrans 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_trans + * 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 = CcTransPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcTransPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcTransPeer::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; + CcTransPeer::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 (CcTrans object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcTransPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcTransPeer::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 + CcTransPeer::NUM_COLUMNS; + } else { + $cls = CcTransPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcTransPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * 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(BaseCcTransPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcTransPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcTransTableMap()); + } + } + + /** + * 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 ? CcTransPeer::CLASS_DEFAULT : CcTransPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcTrans or Criteria object. + * + * @param mixed $values Criteria or CcTrans 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(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcTrans object + } + + if ($criteria->containsKey(CcTransPeer::ID) && $criteria->keyContainsValue(CcTransPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTransPeer::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 CcTrans or Criteria object. + * + * @param mixed $values Criteria or CcTrans 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(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcTransPeer::ID); + $value = $criteria->remove(CcTransPeer::ID); + if ($value) { + $selectCriteria->add(CcTransPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcTransPeer::TABLE_NAME); + } + + } else { // $values is CcTrans 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_trans 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(CcTransPeer::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(CcTransPeer::TABLE_NAME, $con, CcTransPeer::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). + CcTransPeer::clearInstancePool(); + CcTransPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcTrans or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcTrans 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(CcTransPeer::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. + CcTransPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcTrans) { // it's a model object + // invalidate the cache for this single object + CcTransPeer::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(CcTransPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcTransPeer::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); + CcTransPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcTrans 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 CcTrans $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(CcTrans $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcTransPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcTransPeer::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(CcTransPeer::DATABASE_NAME, CcTransPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcTrans + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcTransPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcTransPeer::DATABASE_NAME); + $criteria->add(CcTransPeer::ID, $pk); + + $v = CcTransPeer::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(CcTransPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcTransPeer::DATABASE_NAME); + $criteria->add(CcTransPeer::ID, $pks, Criteria::IN); + $objs = CcTransPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcTransPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcTransPeer::buildTableMap(); + diff --git a/application/models/campcaster/om/BaseCcTransQuery.php b/application/models/campcaster/om/BaseCcTransQuery.php new file mode 100644 index 000000000..e00396ef6 --- /dev/null +++ b/application/models/campcaster/om/BaseCcTransQuery.php @@ -0,0 +1,826 @@ +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 CcTrans|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcTransPeer::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 CcTransQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcTransPeer::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 CcTransQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcTransPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $id 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 CcTransQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcTransPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the trtok column + * + * @param string $trtok 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 CcTransQuery The current query, for fluid interface + */ + public function filterByTrtok($trtok = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($trtok)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $trtok)) { + $trtok = str_replace('*', '%', $trtok); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::TRTOK, $trtok, $comparison); + } + + /** + * Filter the query on the direction column + * + * @param string $direction 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 CcTransQuery The current query, for fluid interface + */ + public function filterByDirection($direction = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($direction)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $direction)) { + $direction = str_replace('*', '%', $direction); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::DIRECTION, $direction, $comparison); + } + + /** + * Filter the query on the state column + * + * @param string $state 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 CcTransQuery The current query, for fluid interface + */ + public function filterByState($state = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($state)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $state)) { + $state = str_replace('*', '%', $state); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::STATE, $state, $comparison); + } + + /** + * Filter the query on the trtype column + * + * @param string $trtype 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 CcTransQuery The current query, for fluid interface + */ + public function filterByTrtype($trtype = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($trtype)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $trtype)) { + $trtype = str_replace('*', '%', $trtype); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::TRTYPE, $trtype, $comparison); + } + + /** + * Filter the query on the lock column + * + * @param string $lock 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 CcTransQuery The current query, for fluid interface + */ + public function filterByLock($lock = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($lock)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $lock)) { + $lock = str_replace('*', '%', $lock); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::LOCK, $lock, $comparison); + } + + /** + * Filter the query on the target column + * + * @param string $target 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 CcTransQuery The current query, for fluid interface + */ + public function filterByTarget($target = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($target)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $target)) { + $target = str_replace('*', '%', $target); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::TARGET, $target, $comparison); + } + + /** + * Filter the query on the rtrtok column + * + * @param string $rtrtok 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 CcTransQuery The current query, for fluid interface + */ + public function filterByRtrtok($rtrtok = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($rtrtok)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $rtrtok)) { + $rtrtok = str_replace('*', '%', $rtrtok); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::RTRTOK, $rtrtok, $comparison); + } + + /** + * Filter the query on the mdtrtok column + * + * @param string $mdtrtok 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 CcTransQuery The current query, for fluid interface + */ + public function filterByMdtrtok($mdtrtok = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($mdtrtok)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $mdtrtok)) { + $mdtrtok = str_replace('*', '%', $mdtrtok); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::MDTRTOK, $mdtrtok, $comparison); + } + + /** + * Filter the query on the gunid column + * + * @param string $gunid 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 CcTransQuery The current query, for fluid interface + */ + public function filterByGunid($gunid = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($gunid)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $gunid)) { + $gunid = str_replace('*', '%', $gunid); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::GUNID, $gunid, $comparison); + } + + /** + * Filter the query on the pdtoken column + * + * @param string|array $pdtoken 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 CcTransQuery The current query, for fluid interface + */ + public function filterByPdtoken($pdtoken = null, $comparison = null) + { + if (is_array($pdtoken)) { + $useMinMax = false; + if (isset($pdtoken['min'])) { + $this->addUsingAlias(CcTransPeer::PDTOKEN, $pdtoken['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($pdtoken['max'])) { + $this->addUsingAlias(CcTransPeer::PDTOKEN, $pdtoken['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::PDTOKEN, $pdtoken, $comparison); + } + + /** + * Filter the query on the url column + * + * @param string $url 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 CcTransQuery The current query, for fluid interface + */ + public function filterByUrl($url = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($url)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $url)) { + $url = str_replace('*', '%', $url); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::URL, $url, $comparison); + } + + /** + * Filter the query on the localfile column + * + * @param string $localfile 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 CcTransQuery The current query, for fluid interface + */ + public function filterByLocalfile($localfile = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($localfile)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $localfile)) { + $localfile = str_replace('*', '%', $localfile); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::LOCALFILE, $localfile, $comparison); + } + + /** + * Filter the query on the fname column + * + * @param string $fname 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 CcTransQuery The current query, for fluid interface + */ + public function filterByFname($fname = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($fname)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $fname)) { + $fname = str_replace('*', '%', $fname); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::FNAME, $fname, $comparison); + } + + /** + * Filter the query on the title column + * + * @param string $title 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 CcTransQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::TITLE, $title, $comparison); + } + + /** + * Filter the query on the expectedsum column + * + * @param string $expectedsum 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 CcTransQuery The current query, for fluid interface + */ + public function filterByExpectedsum($expectedsum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($expectedsum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $expectedsum)) { + $expectedsum = str_replace('*', '%', $expectedsum); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::EXPECTEDSUM, $expectedsum, $comparison); + } + + /** + * Filter the query on the realsum column + * + * @param string $realsum 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 CcTransQuery The current query, for fluid interface + */ + public function filterByRealsum($realsum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($realsum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $realsum)) { + $realsum = str_replace('*', '%', $realsum); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::REALSUM, $realsum, $comparison); + } + + /** + * Filter the query on the expectedsize column + * + * @param int|array $expectedsize 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 CcTransQuery The current query, for fluid interface + */ + public function filterByExpectedsize($expectedsize = null, $comparison = null) + { + if (is_array($expectedsize)) { + $useMinMax = false; + if (isset($expectedsize['min'])) { + $this->addUsingAlias(CcTransPeer::EXPECTEDSIZE, $expectedsize['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($expectedsize['max'])) { + $this->addUsingAlias(CcTransPeer::EXPECTEDSIZE, $expectedsize['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::EXPECTEDSIZE, $expectedsize, $comparison); + } + + /** + * Filter the query on the realsize column + * + * @param int|array $realsize 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 CcTransQuery The current query, for fluid interface + */ + public function filterByRealsize($realsize = null, $comparison = null) + { + if (is_array($realsize)) { + $useMinMax = false; + if (isset($realsize['min'])) { + $this->addUsingAlias(CcTransPeer::REALSIZE, $realsize['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($realsize['max'])) { + $this->addUsingAlias(CcTransPeer::REALSIZE, $realsize['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::REALSIZE, $realsize, $comparison); + } + + /** + * Filter the query on the uid column + * + * @param int|array $uid 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 CcTransQuery The current query, for fluid interface + */ + public function filterByUid($uid = null, $comparison = null) + { + if (is_array($uid)) { + $useMinMax = false; + if (isset($uid['min'])) { + $this->addUsingAlias(CcTransPeer::UID, $uid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($uid['max'])) { + $this->addUsingAlias(CcTransPeer::UID, $uid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::UID, $uid, $comparison); + } + + /** + * Filter the query on the errmsg column + * + * @param string $errmsg 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 CcTransQuery The current query, for fluid interface + */ + public function filterByErrmsg($errmsg = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($errmsg)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $errmsg)) { + $errmsg = str_replace('*', '%', $errmsg); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcTransPeer::ERRMSG, $errmsg, $comparison); + } + + /** + * Filter the query on the jobpid column + * + * @param int|array $jobpid 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 CcTransQuery The current query, for fluid interface + */ + public function filterByJobpid($jobpid = null, $comparison = null) + { + if (is_array($jobpid)) { + $useMinMax = false; + if (isset($jobpid['min'])) { + $this->addUsingAlias(CcTransPeer::JOBPID, $jobpid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($jobpid['max'])) { + $this->addUsingAlias(CcTransPeer::JOBPID, $jobpid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::JOBPID, $jobpid, $comparison); + } + + /** + * Filter the query on the start column + * + * @param string|array $start 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 CcTransQuery The current query, for fluid interface + */ + public function filterByStart($start = null, $comparison = null) + { + if (is_array($start)) { + $useMinMax = false; + if (isset($start['min'])) { + $this->addUsingAlias(CcTransPeer::START, $start['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($start['max'])) { + $this->addUsingAlias(CcTransPeer::START, $start['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::START, $start, $comparison); + } + + /** + * Filter the query on the ts column + * + * @param string|array $ts 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 CcTransQuery The current query, for fluid interface + */ + public function filterByTs($ts = null, $comparison = null) + { + if (is_array($ts)) { + $useMinMax = false; + if (isset($ts['min'])) { + $this->addUsingAlias(CcTransPeer::TS, $ts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ts['max'])) { + $this->addUsingAlias(CcTransPeer::TS, $ts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcTransPeer::TS, $ts, $comparison); + } + + /** + * Exclude object from result + * + * @param CcTrans $ccTrans Object to remove from the list of results + * + * @return CcTransQuery The current query, for fluid interface + */ + public function prune($ccTrans = null) + { + if ($ccTrans) { + $this->addUsingAlias(CcTransPeer::ID, $ccTrans->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcTransQuery diff --git a/application/models/configure b/application/models/configure new file mode 100755 index 000000000..26ccda218 --- /dev/null +++ b/application/models/configure @@ -0,0 +1,47 @@ +#!/bin/sh +#------------------------------------------------------------------------------- +# Copyright (c) 2010 Sourcefabric O.P.S. +# +# This file is part of the Campcaster project. +# http://campcaster.campware.org/ +# +# Campcaster is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Campcaster is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Campcaster; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Run this script to configure the environment. +# +# This script in effect calls the real automake / autoconf configure script +#------------------------------------------------------------------------------- + +# assume we're in $basedir +reldir=`dirname $0` +basedir=`cd $reldir; pwd;` +test -z "$basedir" && basedir=. + +bindir=$basedir/bin +tmpdir=$basedir/tmp + + +autogen=$bindir/autogen.sh +configure=$tmpdir/configure + +if [ ! -x $configure ]; then + (cd $basedir && $autogen $*) +fi + +(cd $tmpdir && $configure $*) + diff --git a/application/models/cron/Cron.php b/application/models/cron/Cron.php new file mode 100755 index 000000000..fba702b62 --- /dev/null +++ b/application/models/cron/Cron.php @@ -0,0 +1,214 @@ + + * $cron = new Cron(); + * $access = $cron->openCrontab('write'); + * if ($access != 'write') { + * do { + * $access = $cron->forceWriteable(); + * } while ($access != 'write'); + * } + * $cron->addCronJob('*','*','*','*','*', + * 'ClassName', + * array('first','secound','third') + * ); + * $cron->closeCrontab(); + *
content
field contains a struct for each playlist
+ * element contained in the playlist. For audio clips, this struct is
+ * of type {url, token}
; for sub-playlists, it is of type
+ * {url, token, chsum, content}
.
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *